Files
notifications-admin/app/main/views/verify.py
Chris Hill-Scott 81d4230b61 Page for adding a new service
This page is exactly the same as the page for adding your first service, save
the heading text.

So all this commit does is:
- set up two routes (`/add-service`, `/add-service/first`) for each of the two
  journeys and change the existing journeys to use the `/add-service/first`
  route
- add logic to show different heading text depending on the journey
- add a link to the new (`/add-service`) route in the service chooser dropdown
2016-01-18 11:03:25 +00:00

25 lines
922 B
Python

from flask import (
render_template, redirect, jsonify, session, url_for)
from flask_login import login_user
from app.main import main
from app.main.dao import users_dao, verify_codes_dao
from app.main.forms import VerifyForm
@main.route('/verify', methods=['GET', 'POST'])
def verify():
# TODO there needs to be a way to regenerate a session id
# or handle gracefully.
user = users_dao.get_user_by_email(session['user_email'])
codes = verify_codes_dao.get_codes(user.id)
form = VerifyForm(codes)
if form.validate_on_submit():
verify_codes_dao.use_code_for_user_and_type(user_id=user.id, code_type='email')
verify_codes_dao.use_code_for_user_and_type(user_id=user.id, code_type='sms')
users_dao.activate_user(user.id)
login_user(user)
return redirect(url_for('.add_service', first='first'))
return render_template('views/verify.html', form=form)