mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 13:39:41 -04:00
Removed exceptions, found a better way to handle them.
Refactored the forms so that fields like email_address can be used in multiple forms. Refactored form validation so that a query function is passed into the form to be run, this way the form is not exposed to the dao layer and the query is more efficient. This PR still requires some frontend attention. Will work with Chris to update the templates.
This commit is contained in:
@@ -3,7 +3,6 @@ from datetime import datetime
|
||||
from sqlalchemy.orm import load_only
|
||||
|
||||
from app import db, login_manager
|
||||
from app.main.exceptions import NoDataFoundException
|
||||
from app.models import User
|
||||
from app.main.encryption import hashpw
|
||||
|
||||
@@ -60,16 +59,11 @@ def update_mobile_number(id, mobile_number):
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def update_password(email, password):
|
||||
user = get_user_by_email(email)
|
||||
if user:
|
||||
user.password = hashpw(password)
|
||||
user.password_changed_at = datetime.now()
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
return user
|
||||
else:
|
||||
raise NoDataFoundException('The user does not exist')
|
||||
def update_password(user, password):
|
||||
user.password = hashpw(password)
|
||||
user.password_changed_at = datetime.now()
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def find_all_email_address():
|
||||
|
||||
Reference in New Issue
Block a user