add user creation using shell
This commit is contained in:
		
							
								
								
									
										19
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								app.py
									
									
									
									
									
								
							@@ -288,5 +288,24 @@ def setup():
 | 
			
		||||
    print('application setup done')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@application.cli.command("create_user")
 | 
			
		||||
def shell_create_user():
 | 
			
		||||
    name = input("User login: ")
 | 
			
		||||
    email = input("User email: ")
 | 
			
		||||
    while True:
 | 
			
		||||
        password1 = getpass(prompt='Password: ')
 | 
			
		||||
        password2 = getpass(prompt='Retype your password: ')
 | 
			
		||||
        if password1 == password2:
 | 
			
		||||
            break
 | 
			
		||||
        print("The passwords dont match")
 | 
			
		||||
    create_user(
 | 
			
		||||
        name=name,
 | 
			
		||||
        password=password1,
 | 
			
		||||
        email=email,
 | 
			
		||||
        is_admin=False
 | 
			
		||||
    )
 | 
			
		||||
    db.session.commit()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    application.run(debug=True)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user