mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 14:28:25 -04:00
Removed some un needed flash messages raised as bugs.
In the process found a couple of edge cases of incorrect use of invitation links by other users which are now handled.
This commit is contained in:
@@ -4,7 +4,8 @@ from flask import (
|
||||
url_for,
|
||||
session,
|
||||
flash,
|
||||
request
|
||||
request,
|
||||
abort
|
||||
)
|
||||
|
||||
from flask.ext.login import (
|
||||
@@ -13,26 +14,40 @@ from flask.ext.login import (
|
||||
confirm_login
|
||||
)
|
||||
|
||||
from app import (
|
||||
user_api_client,
|
||||
invite_api_client,
|
||||
service_api_client
|
||||
)
|
||||
|
||||
|
||||
from app.main import main
|
||||
|
||||
from app import (user_api_client, service_api_client)
|
||||
|
||||
|
||||
from app.main.forms import LoginForm
|
||||
|
||||
|
||||
@main.route('/sign-in', methods=(['GET', 'POST']))
|
||||
def sign_in():
|
||||
|
||||
if current_user and current_user.is_authenticated():
|
||||
return redirect(url_for('main.choose_service'))
|
||||
|
||||
form = LoginForm()
|
||||
if form.validate_on_submit():
|
||||
|
||||
user = user_api_client.get_user_by_email_or_none(form.email_address.data)
|
||||
user = _get_and_verify_user(user, form.password.data)
|
||||
if user and user.state == 'pending':
|
||||
flash("You haven't verified your email or mobile number yet.")
|
||||
return redirect(url_for('main.sign_in'))
|
||||
|
||||
if user and session.get('invited_user'):
|
||||
invited_user = session.get('invited_user')
|
||||
if user.email_address != invited_user['email_address']:
|
||||
flash("You can't accept an invite for another person.")
|
||||
session.pop('invited_user', None)
|
||||
abort(403)
|
||||
else:
|
||||
invite_api_client.accept_invite(invited_user['service'], invited_user['id'])
|
||||
if user:
|
||||
# Remember me login
|
||||
if not login_fresh() and \
|
||||
@@ -56,11 +71,6 @@ def sign_in():
|
||||
# Vague error message for login in case of user not known, locked, inactive or password not verified
|
||||
flash('Username or password is incorrect')
|
||||
|
||||
invited_user = session.get('invited_user')
|
||||
if invited_user:
|
||||
message = 'You already have an account with GOV.UK Notify. Sign in to your account to accept this invitation.'
|
||||
flash(message, 'default')
|
||||
|
||||
return render_template('views/signin.html', form=form)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user