mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
Add endpoints for forgot-password.
This commit is contained in:
@@ -31,3 +31,17 @@ def send_email_code(user_id, email):
|
||||
raise AdminApiClientException('Exception when sending email.')
|
||||
|
||||
return email_code
|
||||
|
||||
|
||||
def send_change_password_email(email):
|
||||
code = create_verify_code()
|
||||
link_to_change_password = 'thelink' + code
|
||||
# TODO needs an expiry date to check?
|
||||
try:
|
||||
admin_api_client.send_email(email_address=email,
|
||||
from_str='notify@digital.cabinet-office.gov.uk',
|
||||
message=link_to_change_password,
|
||||
subject='Verification code',
|
||||
token=admin_api_client.auth_token)
|
||||
except:
|
||||
raise AdminApiClientException('Exception when sending email.')
|
||||
|
||||
21
app/main/views/forgot_password.py
Normal file
21
app/main/views/forgot_password.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from flask import render_template, jsonify
|
||||
|
||||
from app.main import main
|
||||
from app.main.forms import ForgotPassword
|
||||
from app.main.views import send_change_password_email
|
||||
|
||||
|
||||
@main.route('/forgot-password', methods=['GET'])
|
||||
def render_forgot_my_password():
|
||||
return render_template('views/forgot-password.html', form=ForgotPassword())
|
||||
|
||||
|
||||
@main.route('/forgot-password', methods=['POST'])
|
||||
def change_password():
|
||||
form = ForgotPassword()
|
||||
if form.validate_on_submit():
|
||||
send_change_password_email(form.email_address)
|
||||
|
||||
return 'You have been sent an email with a link to change your password'
|
||||
else:
|
||||
return jsonify(form.errors), 400
|
||||
@@ -39,6 +39,21 @@ def forgotpassword():
|
||||
return render_template('views/forgot-password.html')
|
||||
|
||||
|
||||
@main.route("/jobs")
|
||||
def showjobs():
|
||||
return render_template('views/jobs.html')
|
||||
|
||||
|
||||
@main.route("/jobs/job")
|
||||
def showjob():
|
||||
return render_template('views/job.html')
|
||||
|
||||
|
||||
@main.route("/jobs/job/notification")
|
||||
def shownotification():
|
||||
return render_template('views/notification.html')
|
||||
|
||||
|
||||
@main.route("/new-password")
|
||||
def newpassword():
|
||||
return render_template('views/new-password.html')
|
||||
@@ -62,3 +77,12 @@ def apikeys():
|
||||
@main.route("/verification-not-received")
|
||||
def verificationnotreceived():
|
||||
return render_template('views/verification-not-received.html')
|
||||
|
||||
@main.route("/manage-templates")
|
||||
def managetemplates():
|
||||
return render_template('views/manage-templates.html')
|
||||
|
||||
|
||||
@main.route("/edit-template")
|
||||
def edittemplate():
|
||||
return render_template('views/edit-template.html')
|
||||
|
||||
Reference in New Issue
Block a user