def create(email, password): """Creates a user using an email. """ if User.objects(email = email).first() != None: print ('User already exists!') else: CreateUserCommand().run(email=email, password=password, active=1)
def create(email, password): """Creates a user using an email. """ a = User.query.filter(User.email == email).first() if a != None: print 'User already exists!' else: CreateUserCommand().run(email=email, password=password, active=1)
def run(self, **kwargs): #check if admin exists a = Role.objects.filter(name='admin').first() if a == None: Role(name='admin').save() u = prompt('Admin Email?', default='*****@*****.**') p = prompt('Admin Password (min 6 characters)?', default='enferno') CreateUserCommand().run(email=u, password=p, active=1) AddRoleCommand().run(user_identifier=u, role_name='admin') else: print 'Seems like an Admin is already installed'
def install(): """Install a default admin user and add an admin role to it. """ #check if admin exists from enferno.user.models import Role a = Role.objects.filter(name ='admin').first() if a == None: r = Role(name='admin').save() u = click.prompt('Admin Email?',default='*****@*****.**') p = click.prompt('Admin Password (min 6 characters)?',default='enferno') CreateUserCommand().run(email=u,password=p,active=1) AddRoleCommand().run(user_identifier=u,role_name='admin') else: print ('Seems like an Admin is already installed')
#!/usr/bin/env python from flask_script import Manager from flask_script.commands import Server, Shell, ShowUrls, Clean from flask_security.script import CreateUserCommand, AddRoleCommand,\ RemoveRoleCommand, ActivateUserCommand, DeactivateUserCommand from flask_application import app from flask_application.script import ResetDB, PopulateDB from flask_application.tests.script import RunTests manager = Manager(app) manager.add_command("shell", Shell(use_ipython=True)) manager.add_command("runserver", Server(use_reloader=True)) manager.add_command("show_urls", ShowUrls()) manager.add_command("clean", Clean()) manager.add_command("reset_db", ResetDB()) manager.add_command("populate_db", PopulateDB()) manager.add_command('create_user', CreateUserCommand()) manager.add_command('add_role', AddRoleCommand()) manager.add_command('remove_role', RemoveRoleCommand()) manager.add_command('deactivate_user', DeactivateUserCommand()) manager.add_command('activate_user', ActivateUserCommand()) manager.add_command('run_tests', RunTests()) if __name__ == "__main__": manager.run()