()
Add confirmed administrator account
Add confirmed administrator account
Add confirmed administrator account
def make_admin_user():
    "Add confirmed administrator account"
    while True:
        username = input("Username: ")
        user = User.query.filter_by(username=username).one_or_none()
        if user:
            print("Username is already in use")
        else:
            break

    while True:
        email = input("Email: ")
        user = User.query.filter_by(email=email).one_or_none()
        if user:
            print("Email address already in use")
        else:
            break

    while True:
        password = getpass("Password: ")
        password_again = getpass("Type your password again: ")

        if password == password_again:
            break
        print("Passwords did not match")

    u = User(username=username, email=email, password=password,
             confirmed=True, is_administrator=True)
    db.session.add(u)
    db.session.commit()
    print("Administrator {} successfully added".format(username))
    current_app.logger.info('Administrator {} added with email {}'.format(username,
                                                                          email))
def make_admin_user ( ) : while True : username = input ( "Username: " ) user = User . query . filter_by ( username = username ) . one_or_none ( ) if user : print ( "Username is already in use" ) else : break while True : email = input ( "Email: " ) user = User . query . filter_by ( email = email ) . one_or_none ( ) if user : print ( "Email address already in use" ) else : break while True : password = getpass ( "Password: " ) password_again = getpass ( "Type your password again: " ) if password == password_again : break print ( "Passwords did not match" ) u = User ( username = username , email = email , password = password , confirmed = True , is_administrator = True ) db . session . add ( u ) db . session . commit ( ) print ( "Administrator {} successfully added" . format ( username ) ) current_app . logger . info ( 'Administrator {} added with email {}' . format ( username , email ) )