-
Notifications
You must be signed in to change notification settings - Fork 332
SQSERVICES 1099 Public API end-point for re-sending email validation #1948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
de76f70
660307f
f812372
64150ae
11d3fda
7040a48
cfad5e6
6a387d3
5df2101
2a12fdb
de412b1
6bc4778
d8ed216
f01d988
69848bb
abc3938
18a749b
cab6d98
7e5a109
1743a06
37add87
dc6ff6b
ca6e70e
6101c97
a79658e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| A new endpoint is added to Brig (`put /users/:uid/email`) that allows a team owner to initiate changing/setting a user email by (re-)sending an activation email. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -404,7 +404,7 @@ lookupRichInfoMultiUsers users = do | |
| -- successful login. | ||
| lookupUserTeam :: UserId -> AppIO (Maybe TeamId) | ||
| lookupUserTeam u = | ||
| join . fmap runIdentity | ||
| (runIdentity =<<) | ||
| <$> retry x1 (query1 teamSelect (params LocalQuorum (Identity u))) | ||
|
|
||
| lookupAuth :: (MonadClient m) => UserId -> m (Maybe (Maybe Password, AccountStatus)) | ||
|
|
@@ -471,7 +471,7 @@ lookupFeatureConferenceCalling uid = do | |
| pure $ ApiFt.TeamFeatureStatusNoConfig <$> mStatusValue | ||
| where | ||
| select :: PrepQuery R (Identity UserId) (Identity (Maybe ApiFt.TeamFeatureStatusValue)) | ||
| select = fromString $ "select feature_conference_calling from user where id = ?" | ||
| select = fromString "select feature_conference_calling from user where id = ?" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, these changes would go into a separate PR.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know, but this makes the barrier for improving the code on the fly much higher. |
||
|
|
||
| ------------------------------------------------------------------------------- | ||
| -- Queries | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,9 +141,58 @@ tests _ at opts p b c ch g aws = | |
| testGroup | ||
| "temporary customer extensions" | ||
| [ test' aws p "domains blocked for registration" $ testDomainsBlockedForRegistration opts b | ||
| ], | ||
| testGroup | ||
| "update user email by team owner" | ||
| [ test' aws p "put /users/:uid/email" $ testUpdateUserEmailByTeamOwner b | ||
| ] | ||
| ] | ||
|
|
||
| testUpdateUserEmailByTeamOwner :: Brig -> Http () | ||
| testUpdateUserEmailByTeamOwner brig = do | ||
| (_, teamOwner, emailOwner : otherTeamMember : _) <- createPopulatedBindingTeamWithNamesAndHandles brig 2 | ||
battermann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (teamOwnerDifferentTeam, _) <- createUserWithTeam' brig | ||
| newEmail <- randomEmail | ||
| initiateEmailUpdateNoSend brig newEmail (userId emailOwner) !!! (const 202 === statusCode) | ||
| checkActivationCode newEmail True | ||
| checkLetActivationExpire newEmail | ||
| checkActivationCode newEmail False | ||
| checkSetUserEmail teamOwner emailOwner newEmail 200 | ||
| checkActivationCode newEmail True | ||
| checkUnauthorizedRequests emailOwner otherTeamMember teamOwnerDifferentTeam newEmail | ||
| activateEmail brig newEmail | ||
| -- apparently activating the email does not invalidate the activation code | ||
| -- therefore we let the activation code expire again | ||
| checkLetActivationExpire newEmail | ||
| checkSetUserEmail teamOwner emailOwner newEmail 200 | ||
battermann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| checkActivationCode newEmail False | ||
| checkUnauthorizedRequests emailOwner otherTeamMember teamOwnerDifferentTeam newEmail | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove this line? ff not, can you add a comment helping me to find out what this is testing?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 168: Ideally if the email has been verified the team owner can call the endpoint again and nothing will happen (no new activation code will be generated). In order to test this specifically we would have to wait until the activation code expires. This is too costly for the test, but at least we can test that the request still responds with status code 200 in this case. Line: 169: Similar, if the request is made with insufficient permissions, the responses should be the same as before (regardless of the state of the activation)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe these are not the most useful tests, but they don't hurt.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed in another conversation, I added the expiration of the token again, so this conversation is obsolete, I think. |
||
| checkActivationCode newEmail False | ||
| where | ||
| checkLetActivationExpire :: Email -> Http () | ||
| checkLetActivationExpire email = do | ||
| -- assumption: `optSettings.setActivationTimeout = 5` in `brig.yaml` | ||
| threadDelay (5100 * 1000) | ||
| checkActivationCode email False | ||
|
|
||
| checkActivationCode :: Email -> Bool -> Http () | ||
| checkActivationCode email shouldExist = do | ||
| maybeActivationCode <- Util.getActivationCode brig (Left email) | ||
| void $ | ||
| lift $ | ||
| if shouldExist | ||
| then assertBool "activation code should exists" (isJust maybeActivationCode) | ||
| else assertBool "activation code should not exists" (isNothing maybeActivationCode) | ||
|
|
||
| checkSetUserEmail :: User -> User -> Email -> Int -> Http () | ||
| checkSetUserEmail teamOwner emailOwner email expectedStatusCode = | ||
| setUserEmail brig (userId teamOwner) (userId emailOwner) email !!! (const expectedStatusCode === statusCode) | ||
|
|
||
| checkUnauthorizedRequests :: User -> User -> User -> Email -> Http () | ||
| checkUnauthorizedRequests emailOwner otherTeamMember teamOwnerDifferentTeam email = do | ||
| setUserEmail brig (userId teamOwnerDifferentTeam) (userId emailOwner) email !!! (const 404 === statusCode) | ||
| setUserEmail brig (userId otherTeamMember) (userId emailOwner) email !!! (const 403 === statusCode) | ||
|
|
||
| testCreateUserWithPreverified :: Opt.Opts -> Brig -> AWS.Env -> Http () | ||
| testCreateUserWithPreverified opts brig aws = do | ||
| -- Register (pre verified) user with phone | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.