Commit Graph

74 Commits

Author SHA1 Message Date
Kenneth Kehl
42184a17cd fix flake8 2024-07-25 12:38:33 -07:00
Kenneth Kehl
1bdb291397 debug 2024-07-24 07:13:34 -07:00
Kenneth Kehl
b50e90e6ee merge from main 2024-07-12 10:09:48 -07:00
Kenneth Kehl
da96edbfcd fix set and get in redis_client 2024-06-07 09:07:42 -07:00
Carlo Costino
9a83ba7475 Localize notification_utils to the admin
This changeset pulls in all of the notification_utils code directly into the admin and removes it as an external dependency. We are doing this to cut down on operational maintenance of the project and will begin removing parts of it no longer needed for the admin.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2024-05-16 10:37:37 -04:00
Kenneth Kehl
f7fe270171 fix service invites 2024-04-24 11:20:17 -07:00
Kenneth Kehl
410256821e remove misleading comment 2024-04-19 14:39:52 -07:00
Kenneth Kehl
fe7ad71edf remove need to double down on json.loads 2024-04-19 14:11:32 -07:00
Kenneth Kehl
5b97f33831 fix flow and skip tests for now 2024-04-19 13:53:32 -07:00
Kenneth Kehl
1ba6d200ee fix typo 2024-04-19 08:18:21 -07:00
Kenneth Kehl
41e72a4b17 add debug 2024-04-19 07:55:45 -07:00
Kenneth Kehl
e8c3870cab add debug 2024-04-19 07:51:18 -07:00
Kenneth Kehl
7ed7b4e1f4 fix service invites 2024-04-18 14:01:33 -07:00
Kenneth Kehl
e4990cfd70 remove debug 2024-04-01 12:55:37 -07:00
Kenneth Kehl
9b1c9b8ccf ugh 2024-03-28 11:35:25 -07:00
Kenneth Kehl
b29c2a3a62 debug staging 2024-03-28 11:15:10 -07:00
Kenneth Kehl
8362c6b975 fix invites for service and organization 2024-03-22 11:08:49 -07:00
Kenneth Kehl
8c9721d8e2 notify-api-412 use black to enforce python coding style 2023-08-25 09:12:23 -07:00
Kenneth Kehl
c6eb007386 merge from main 2023-08-25 08:57:24 -07:00
Steven Reilly
13d0e46b52 blunt rename of org (#620) 2023-07-12 12:09:44 -04:00
stvnrlly
f16b5dd1c4 remove broadcast-related code 2022-10-04 03:04:13 +00:00
Ben Thorner
8d5974eb47 Simplify "activate_user" to clear session earlier
A snippet of old code [^1] in "activate_user" was forcing us to
keep "user_details" in the session until the very last moment with
a "try / finally" combo. But "activate_user" already knows the ID
of the user: it's the argument we pass to the function.

None of the functions called by "activate_user" require the session
to have that key either i.e. it's definitely redundant.

It's unclear if we need to pop the key from the session in both
"verify" methods - there are no tests covering this behaviour. For
now, we can at least make the flow clearer by adjusting where we do
the "pop" and the assignment.

[^1]: bbc7b173f0 (diff-d12384ece5ad90e9b66063fd3ab170453788d36b7e0babf49ee016f0a880f251L71)
2022-03-07 11:08:19 +00:00
Pea Tyczynska
ae4fc977c1 Apply suggestions from code review
Co-authored-by: Ben Thorner <benthorner@users.noreply.github.com>
2022-03-03 17:02:26 +00:00
Pea Tyczynska
8112930e24 Do not verify sms for pending users with email auth
This is to fix a bug where a user creates an account but doesn't
complete registration, then they are invited to a service that
changes their auth to email_auth, and then when they try to
complete registration they are still asked for sms code.

It should save users some pain, and reduce number of support tickets.
2022-03-03 17:02:26 +00:00
Ben Thorner
3250f2b3ed Move redirect_to_signin helper to new util module
We'll expand this module in later commits.
2021-06-14 11:09:42 +01:00
Leo Hemsted
c203f624ca rename two_factor to two_factor_sms
it's a bit confusing now that there are three endpoints. the other two
are already renamed two_factor_email and two_factor_webauthn
2021-06-01 19:08:57 +01:00
Chris Hill-Scott
5de1c4f6ca Redirect newly-created users to broadcast tour 2021-05-19 11:48:59 +01:00
Leo Hemsted
45297eae43 store invited user ids in session
same as the invited org user ids in the previous commit
2021-03-15 12:21:58 +00:00
Leo Hemsted
6d62c9ba36 store invited org user ids in session
first of a two step process to remove invited user objects from the
session. we're removing them because they're of variable size, and with
a lot of folder permissions they can cause the session to exceed the 4kb
cookie size limit and not save properly.

this commit looks at invited org users only.

in this step, start saving the invited org user's id to the
session alongside the session object. Then, if the invited_org_user_id
is present in the next step of the invite flow, fetch the user object
from the API instead of from the session. If it's not present (due to a
session set by an older instance of the admin app), then just use the
old code to get the entire object out of the session.

For invites where the user is small enough to persist to the cookie,
this will still save both the old and the new way, but will always make
an extra check to the API, I think this minor performance hit is totally
fine. For invites where the user is too big to persist, they'll still
fail for now, and will need to wait until the next PR comes along and
stops saving the large invited user object to the session entirely.
2021-03-12 16:36:02 +00:00
Katie Smith
7ae4017d50 Add audit event for inviting users to a service 2021-03-08 14:34:50 +00:00
Chris Hill-Scott
19b42e3331 Add a tour for users new to broadcast services
This is an initial, prototype-quality attempt at introducing some kind
of tour for users new to broadcasting. A lot of the users we’re speaking
to don’t have a good concept of what broadcasting means, which is
causing usability problems down the line.

We did a similar thing in the early days of Notify to explain the
concept of message templates and personalisation.
2020-08-03 14:13:48 +01:00
Katie Smith
dede87c95e Always add user to service using User.add_to_service
The `_add_invited_user_to_service` function was calling the
`user_api_client` directly to add a user to a service. It now calls the
`add_to_service` method on the User model instead so that there is only
one place in the code that calls the `user_api_client`.
2020-05-19 11:36:59 +01:00
Chris Hill-Scott
bd9acb1310 Make invited user model inherit from JSONModel
This is more consistent, and less fiddly that always having to call it
with a dictionary expansion.
2019-06-05 14:39:02 +01:00
Chris Hill-Scott
628e344b36 Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
                         API (returns JSON)
                                  ⬇
          API client (returns a built in type, usually `dict`)
                                  ⬇
          Model (returns an instance, eg of type `Service`)
                                  ⬇
                         View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:

```
                         API (returns JSON)
                                  ⬇
    API client (returns a model, of type `User`, `InvitedUser`, etc)
                                  ⬇
                         View (returns HTML)
```

This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.

It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.

For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-06-05 11:13:41 +01:00
Katie Smith
c675925fd1 Upgrade pyexcel-io, which also upgrades Werkzeug
Upgraded pyexcel-io from 0.5.14 to 0.5.16. This change causes Werkzeug
to be upgraded from 0.14.1 to 0.15.1 which requires some changes:

* ProxyFix now needs to be imported from a different location
* The status code of RequestRedirect has changed from 301 to 308. Since
status code 308 is not currently supported on Internet Explorer with
Windows 7 and 8.1, this subclasses RequestRedirect to keep the status
code of 301.

changelog: https://werkzeug.palletsprojects.com/en/0.15.x/changes/#version-0-15-0
2019-03-22 14:18:44 +00:00
Katie Smith
c39f6d49ea Set folder permissions when creating and accepting invites to services
Added a folder permissions form to the page to invite users to services.
This only shows if the service has 'edit_folder_permissions' enabled,
and all folder checkboxes are checked by default. This change means that
InviteApiClient.create_invite now sends folder_permissions through to
notifications_api (so invites get created with folder permissions).

Started passing the folder_permissions through to notifications-api when
accepting an invite. This changes UserApiClient.add_user_to_service to
send folder_permissions to notifications_api so that new users get folder
permissions when they are added to the service.
2019-03-21 10:17:05 +00:00
Katie Smith
bbc7b173f0 Ensure non-gov invited users get added to services
We were adding invited users to services in the `main.add_service` view
function as the last step in the process of inviting users. Since this
view function is decorated with `@user_is_gov_user`, invited users with
non-governmental email addresses would never reach this point and would
be able to register an account but would not get linked to a service.

To fix this, we now add the invited user to the service at the point at
which the user gets activated and also ensure that non-gov users don't
get redirected to a page which they don't have permission to view.
2019-01-22 09:52:55 +00:00
Chris Hill-Scott
f3a0c505bd Enforce order and style of imports
Done using isort[1], with the following command:
```
isort -rc ./app ./tests
```

Adds linting to the `run_tests.sh` script to stop badly-sorted imports
getting re-introduced.

Chosen style is ‘Vertical Hanging Indent’ with trailing commas, because
I think it gives the cleanest diffs, eg:
```
from third_party import (
    lib1,
    lib2,
    lib3,
    lib4,
)
```

1. https://pypi.python.org/pypi/isort
2018-02-27 16:35:13 +00:00
chrisw
22bbc0d6d8 invite-team-members 2018-02-23 11:43:13 +00:00
chrisw
79393c97ef Updated invite email auth user flow 2017-11-14 15:18:14 +00:00
Leo Hemsted
aff9d47323 don't hit API when checking new account email-token
we currently store new account email verify tokens in the database, and
check against that to work out if they've expired. But we don't need to
do that, tokens have their own timing mechanism. So lets just use that,
and free up the database to do other things.

Also, standardised the forgot password, change email, and new account
email verification timeouts to all be an hour, from the config val
'EMAIL_EXPIRY_SECONDS'
2017-11-01 15:32:24 +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
539950d772 when not logged in, redirect to sign-in
parts of the initial setup/login stages were throwing 500s if user
not already in process (ie: user directly navigated to url):
* /resend-email-verification
* /text-not-received
* /send-new-code
* verify
2016-06-17 13:53:48 +01:00
Adam Shimali
09117e5eeb Updated flask-login to version 0.3.2 2016-05-04 14:06:14 +01:00
Rebecca Law
1fe5ae0371 This pull request removes the need for the req and pay in the claims JWT.
Use the new version of the notifications-python-client. This version no longer adds the req and pay to the claims of the jwt.

The change is backward compatible so an older client that sends a JWT with the extra claims will pass authentication.
Once all the clients have been updated to not include the extra claims some updates to exclude them from the method signatures will happen as well.

The documentation has been updated to reflect this change.

https://www.pivotaltracker.com/story/show/116971293
2016-04-15 11:04:35 +01:00
Nicholas Staples
3865c722fc Updated notifications_utils version and associated code. Added email subject formatting for placeholders. 2016-04-14 12:00:55 +01:00
Adam Shimali
db24a633c1 Better flash message for users with active accounts who click on
verification link again.
2016-03-29 13:21:51 +01:00
Adam Shimali
352f169fb1 If user is pending it means they have not verified email yet
Added better checking on re use of consumed verification link.
2016-03-29 13:12:06 +01:00
Adam Shimali
8fc154d3d2 When user clicks on verification link but doesn't complete
verification, if they try to use link again the code will
have been used. Therefore they will need a new email with new
link to use for verification.
2016-03-22 13:43:44 +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