예제 #1
0
def register_user(login, password, mail, name) -> User:
    session = db_session.create_session()
    user = User()
    auth = Auth()

    user.is_approved = False
    user.name = name
    user.role = 'user'
    user.key = geherate_key()
    auth.login = login
    auth.password = password
    auth.email = mail
    user.auth.append(auth)

    session.add(user)
    session.flush()

    application = Applications()
    application.user_id = user.id
    application.login = login
    session.add(application)

    session.commit()
    session.close()
    return user
예제 #2
0
def register_admin(login, password, mail, name) -> User:
    session = db_session.create_session()
    user = User()
    auth = Auth()
    user.is_approved = True
    user.name = name
    user.role = 'admin'
    user.key = geherate_key()
    auth.login = login
    auth.password = password
    auth.email = mail
    user.auth.append(auth)
    session.add(user)
    session.commit()
    session.close()