Commit Graph

62 Commits

Author SHA1 Message Date
Rebecca Law
35f61125e8 Fix the user flow when the user account is locked.
The user has 10 tries at the password, after which the account is locked.
The same is true for the verify code, the user will have 10 tries before the user account is locked.
2017-02-28 14:41:31 +00:00
Rebecca Law
2d4e0a0631 Added a reset of failed_login_count when the user is activated.
Update user from the update-password api call (which resets the failed_login_count)
2017-02-28 11:56:40 +00:00
Leo Hemsted
4df12f5f4e ensure other 2FA pages also handle session id
specifically, the 2FA page when you first create an account is different to the login 2FA page
and also the 2FA page when you change your phone number is different as well
2017-02-24 16:32:59 +00:00
Leo Hemsted
f14a836baa check users' session id.
when a user enters their 2FA code, the API will store a random UUID
against them in the database - this code is then stored on the cookie
on the front end.

At the beginning of each authenticated request, we do the following
steps:
  * Retrieve the user's cookie, and get the user_id from it
  * Request that user's details from the database
  * populate current_user with the DB model
  * run the login_required decorator, which calls
    current_user.is_authenticated

is_authenticated now also checks that the database model matches the
cookie for session_id. The potential states and meanings are as follows:

 database | cookie | meaning
----------+--------+---------
 None     | None   | New user, or system just been deployed.
          |        | Redirect to start page.
----------+--------+---------
 'abc'    | None   | New browser (or cleared cookies). Redirect to
          |        | start page.
----------+--------+---------
 None     | 'abc'  | Invalid state (cookie is set from user obj, so
          |        | would only happen if DB is cleared)
----------+--------+---------
 'abc'    | 'abc'  | Same browser. Business as usual
----------+--------+---------
 'abc'    | 'def'  | Different browser in cookie - db has been changed
          |        | since then. Redirect to start
2017-02-22 17:31:13 +00:00
Imdad Ahad
7ad56df78b Change user api client to update password with new endpoint 2017-02-07 13:31:46 +00:00
Martyn Inglis
08dc8fb13d Use the local APIClient rather than the one from the python-api-client
- ensures that all API calls set the request ID when talking to the API.
2016-11-30 17:01:44 +00:00
Imdad Ahad
1da498164f Use POST req to update a user attr 2016-11-10 12:10:01 +00:00
Imdad Ahad
f3ca33dad3 Revert original update user method and add new attribute update (with strict checking) 2016-11-09 15:06:02 +00:00
Imdad Ahad
f14c3dbfa5 Stop passing the 'whole' user object when making changes to profile 2016-11-03 11:20:24 +00:00
Rebecca Law
a0e7d569e9 Send an email to the user when they change email address
This PR changes the flow to change an email address.
Once the user enter their password, they are told "Check your email".
An email has been sent to them containing a link to notify which contains an encrypted token.
The encrypted token contains the user id and new email address. Once the link is clicked the user's email address is updated to the new email address.
They are redirected to the /user-profile page.

Also in this commit is an update from flask.ext.login to flask_login.
2016-10-13 17:05:37 +01:00
imdadahad
69c16cb0e4 Merge pull request #936 from alphagov/fix-forgot-password-empty-user-issue
Fix exception raised when a pending user attempts to complete 'forgotten password' flow
2016-09-13 15:39:29 +01:00
Chris Hill-Scott
92aacc1a54 Remove extraneous arguments to super
> dont need self.__class__, self in super - that's a python 2.x crutch.
> super() is equivalent
2016-09-12 14:59:53 +01:00
Chris Hill-Scott
5fda35c89d Make it clear that client do not use __init__
The clients never get passed useful values to their `__init__` methods.
Rather the real values are passed through later using the `init_app`
method.

So it should be an error if the client is relying on the values that
get passed to it’s init method. Easiest way to ensure this is by making
the `__init__` method not expect any arguments and passing fake values
to the `Super` call.
2016-09-12 12:18:19 +01:00
Imdad Ahad
9eab8a726f - Add test to check that two-factor auth activates a user as expected
- Ensure DB user activation statusupdate only executed when required
- Fix test_should_activate_user_after_verify
2016-09-09 15:22:56 +01:00
Chris Hill-Scott
fa5e5475e9 Update Python client
Just so that nobody else has to do it.

Implements:
- [x] https://github.com/alphagov/notifications-python-client/pull/29

Which is a breaking change requiring the renaming of method arguments.
2016-09-08 15:55:07 +01:00
Rebecca Law
43938936f3 If a user has already registered with the email they will get a different email when the register again.
The email includes likes to sign in and send feedback
2016-07-12 11:53:30 +01:00
Rebecca Law
cdd666a23b Add api client call to email users that are already registered 2016-07-08 11:00:23 +01:00
Adam Shimali
813e1c3351 Expand permissions to all possible values on admin before posting to
api. This makes template work for both existing and invited users.

API will no longer need to convert from what ui presents as permissions
2016-06-06 12:40:21 +01:00
Nicholas Staples
471eac209e Handling template content size error. All tests passing. 2016-04-29 09:38:59 +01:00
Rebecca Law
461b374f68 Do not throw 404 if email address is not found on sign in.
https://www.pivotaltracker.com/story/show/115947639
2016-03-21 11:48:16 +00:00
Adam Shimali
2792bece54 Changed registration flow to first send email verification link that
when visited sends sms code for second step of account verification.

At that second step user enters just sms code sent to users mobile
number.

Also moved dao calls that simply proxied calls to client to calling
client directly.

There is still a place where a user will be a sent a code for
verification to their email namely if they update email address.
2016-03-17 15:19:51 +00:00
Rebecca Law
f6d98b63ea Refactored register_errorhandlers so that it handles HTTPError
Remove most cases where we catch HTTPError
2016-03-10 11:53:29 +00:00
Rebecca Law
29ddad60e7 Merge branch 'master' into forgot-password
Conflicts:
	app/main/views/two_factor.py
2016-03-08 15:03:25 +00:00
Rebecca Law
3e969b3640 Re-implement forgot password 2016-03-07 18:18:52 +00:00
Adam Shimali
a974e6e157 [WIP] Add call to api to update invitation to accepted.
When flow for invited user is complete, that is
when user has been added to service, update invitation
to accepted
2016-03-03 18:13:56 +00:00
Adam Shimali
1ff9d671eb [WIP] pass invite instead of permissions to make update of invite easier if all goes well 2016-03-03 16:37:22 +00:00
Nicholas Staples
1f2fe2a1e4 Fixed up client for permission setting. All tests passing. 2016-03-03 10:24:49 +00:00
Adam Shimali
6ba13a6513 [WIP] New user can now accept invite and will be made to
register. On succesful register and verfication they
will be added to service and forwarded to dashboard.

Nothing is done yet with the permissions requested in the
invite to the user.
2016-03-02 17:52:32 +00:00
Adam Shimali
98169550d8 [WIP] no data needed for post to create add user to service 2016-03-01 17:32:04 +00:00
Adam Shimali
5f02d4cefe [WIP] Post does not need any data
Invites rest module can use invited user object instead
of dict.
2016-03-01 17:23:23 +00:00
Adam Shimali
5f3c72729e [WIP] Start of user accepting invite.
This commit only deals with acceptance by
users who are already in system.

Changed invite client to return invited user objects
instead of dictionaries.

Added commented out test. fixed up fixtures to return invited user
object for invites
2016-03-01 14:10:35 +00:00
Martyn Inglis
7b5e8061e2 Slight (bad) hack to ensure that the ticks appear on the manage user page
- changes imports for utils from broken version on previous branch
2016-03-01 10:45:13 +00:00
Nicholas Staples
58351a094c Merge with master. 2016-02-29 14:59:15 +00:00
Nicholas Staples
48943527ec API keys hooked up and working. All tests passing. 2016-02-29 14:57:07 +00:00
Adam Shimali
602d505dc7 Merge pull request #196 from alphagov/get-users-for-service
Get users for service
2016-02-24 17:41:45 +00:00
Nicholas Staples
c959678c49 Remember me functionality added and tested.
Merge extra.

Fixed comment.
2016-02-24 17:32:15 +00:00
Rebecca Law
2905d11fe4 Get users for service to show on the manage team page.
Calls api endpoint /service/<service_id>/users to retrieve all users associated with the service
2016-02-24 17:32:15 +00:00
Adam Shimali
d6f88f79e2 Admin uses correct endpoint for getting user by email address. 2016-02-23 12:47:48 +00:00
Nicholas Staples
980c01e10c Fix bug with send_verify_code not including the to field. 2016-02-22 12:33:59 +00:00
Adam Shimali
b4ddcaa9b1 Merge pull request #185 from alphagov/user_permission
User permissions added with test.
2016-02-22 10:36:50 +00:00
Nicholas Staples
32e37d89fb User permissions added with test. 2016-02-19 16:38:04 +00:00
Rebecca Law
cffd66c62e Updated the api_client call to send_verify_code
The api has now has an user/<user_id>/email-code and user/<user_id>/sms-code
This commit requires an update to the python-client. Make sure the PR for that version has been merged first and the tag push using scripts/push_tag.sh
2016-02-19 16:08:44 +00:00
Rebecca Law
8d6c61f3ad Merge pull request #172 from alphagov/upgrade_notifications_python_client
notifications-python_client upgraded to 0.2.5
2016-02-12 09:46:15 +00:00
Nicholas Staples
737e490276 Fix error with invalid token causing an error. 2016-02-11 16:23:41 +00:00
Nicholas Staples
48368584d9 notifications-python_client upgraded to 0.2.5 2016-02-11 15:27:08 +00:00
Adam Shimali
5f52c0d3d6 Inherit from flask usermixin for default implementation of
is_authenticated and is_anonymous
2016-01-28 15:34:02 +00:00
Nicholas Staples
c123098e14 Bug fixes. 2016-01-27 17:26:22 +00:00
Nicholas Staples
ff8a727759 Fix for updated client. 2016-01-27 17:13:56 +00:00
Nicholas Staples
2d35f5f36a All tests passing and merged with master. 2016-01-27 16:30:33 +00:00
Nicholas Staples
6959d695d3 Working tests, hopefully all code changes done. 2016-01-27 12:22:32 +00:00