Merge branch 'master' of github.com:alphagov/notifications-admin into api-keys-flow

Conflicts:
	tests/app/main/views/test_api_keys.py
This commit is contained in:
Rebecca Law
2016-01-21 12:31:28 +00:00
30 changed files with 419 additions and 316 deletions

View File

@@ -1,39 +1,12 @@
templates = [
{
'type': 'sms',
'name': 'Confirmation',
'body': 'Lasting power of attorney: Weve received your application. Applications take between 8 and 10 weeks to process.' # noqa
'name': 'Confirmation with details Jan 2016',
'body': '((name)), weve received your ((thing)). Well contact you again within 1 week.'
},
{
'type': 'sms',
'name': 'Reminder',
'body': 'Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)). Tax your vehicle at www.gov.uk/vehicle-tax' # noqa
},
{
'type': 'sms',
'name': 'Warning',
'body': 'Vehicle tax: Your vehicle tax for ((registration number)) has expired. Tax your vehicle at www.gov.uk/vehicle-tax' # noqa
},
{
'type': 'email',
'name': 'Application alert 06/2016',
'subject': 'Your lasting power of attorney application',
'body': """Dear ((name)),
When youve made your lasting power of attorney (LPA), you need to register it \
with the Office of the Public Guardian (OPG).
You can apply to register your LPA yourself if youre able to make your own decisions.
Your attorney can also register it for you. Youll be told if they do and you can \
object to the registration.
It takes between 8 and 10 weeks to register an LPA if there are no mistakes in the application.
"""
},
{
'type': 'sms',
'name': 'Air quality alert',
'body': 'Air pollution levels will be ((level)) in ((region)) tomorrow.'
},
'name': 'Confirmation Jan 2016',
'body': 'Weve received your payment. Well contact you again within 1 week.'
}
]

View File

@@ -4,14 +4,12 @@ from flask import (
render_template,
redirect,
session,
current_app,
abort
)
from client.errors import HTTPError
from app.main import main
from app.models import User
from app.main.dao import users_dao
from app.main.forms import RegisterUserForm
@@ -27,7 +25,6 @@ def register():
form = RegisterUserForm(users_dao.get_user_by_email)
if form.validate_on_submit():
try:
user = user_api_client.register_user(form.name.data,
form.email_address.data,

View File

@@ -16,6 +16,8 @@ def sign_in():
if form.validate_on_submit():
user = users_dao.get_user_by_email(form.email_address.data)
if user:
# TODO move to user API in next pr to actually do password check as this
# is totally broken now
if not user.is_locked() and user.is_active() and check_hash(form.password.data, user.password):
send_sms_code(user.id, user.mobile_number)
session['user_email'] = user.email_address

View File

@@ -1,11 +1,13 @@
from flask import (
render_template,
redirect,
jsonify,
session,
url_for
url_for,
abort
)
from client.errors import HTTPError
from flask_login import login_user
from app.main import main
@@ -24,9 +26,15 @@ def verify():
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')
# TODO complete verify and login flow
# users_dao.activate_user(user.id)
# login_user(user)
try:
user = users_dao.get_user_by_id(user_id)
activated_user = users_dao.activate_user(user)
login_user(activated_user)
return redirect(url_for('main.add_service', first='first'))
except HTTPError as e:
if e.status_code == 404:
abort(404)
else:
raise e
return redirect(url_for('.add_service', first='first'))
return render_template('views/verify.html', form=form)