mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
When a person registers with a valid mobile number and email address, a code will be sent to each. That person can enter the verify codes and continue to the add-service page.
40 lines
812 B
Python
40 lines
812 B
Python
from app import db, login_manager
|
|
from app.models import User
|
|
from app.main.encryption import hashpw
|
|
|
|
|
|
@login_manager.user_loader
|
|
def load_user(user_id):
|
|
return get_user_by_id(user_id)
|
|
|
|
|
|
def insert_user(user):
|
|
user.password = hashpw(user.password)
|
|
db.session.add(user)
|
|
db.session.commit()
|
|
|
|
|
|
def get_user_by_id(id):
|
|
return User.query.filter_by(id=id).first()
|
|
|
|
|
|
def get_all_users():
|
|
return User.query.all()
|
|
|
|
|
|
def get_user_by_email(email_address):
|
|
return User.query.filter_by(email_address=email_address).first()
|
|
|
|
|
|
def increment_failed_login_count(id):
|
|
user = User.query.filter_by(id=id).first()
|
|
user.failed_login_count += 1
|
|
db.session.commit()
|
|
|
|
|
|
def activate_user(id):
|
|
user = get_user_by_id(id)
|
|
user.state = 'active'
|
|
db.session.add(user)
|
|
db.session.commit()
|