[CORL-220] Change email address (#2461)

* change email form

* add update email mutation

* validate new email addresses

* add email verification callout

* add translation strings

* fix submit button logic

* rename model methods

* style email verifcation box

* resend email verificatoin button

* show success message on email resend

* update user profile email

* fix duplicate import

* add change email spec

* fix profile spacing

* update snapshots

* update snaps

* add preventSubmit function to email change component

* update business logic for profile updating

* update logic for when users can update email or username

* check for less specific duplicate email error

* prevent sso-only users from editing email

* only allow email and username edit if enabeld in local profile

* use generic server error for cannot update profile

* remove merge conflict

* fix tests

* extract logic to get auth integrations

* fix merge error
This commit is contained in:
Tessa Thornton
2019-08-20 12:28:14 -04:00
committed by GitHub
parent 0f02b05689
commit ee93267d97
18 changed files with 1016 additions and 69 deletions
+14 -1
View File
@@ -17,6 +17,7 @@ import {
suspend,
updateAvatar,
updateEmail,
updateEmailByID,
updatePassword,
updateRole,
updateUsername,
@@ -38,6 +39,7 @@ import {
GQLSetPasswordInput,
GQLSetUsernameInput,
GQLSuspendUserInput,
GQLUpdateEmailInput,
GQLUpdatePasswordInput,
GQLUpdateUserAvatarInput,
GQLUpdateUserEmailInput,
@@ -140,7 +142,18 @@ export const Users = (ctx: TenantContext) => ({
ctx.user!
),
updateUserEmail: async (input: GQLUpdateUserEmailInput) =>
updateEmail(ctx.mongo, ctx.tenant, input.userID, input.email),
updateEmailByID(ctx.mongo, ctx.tenant, input.userID, input.email),
updateEmail: async (input: GQLUpdateEmailInput) =>
updateEmail(
ctx.mongo,
ctx.tenant,
ctx.mailerQueue,
ctx.config,
ctx.signingConfig!,
ctx.user!,
input.email,
input.password
),
updateUserAvatar: async (input: GQLUpdateUserAvatarInput) =>
updateAvatar(ctx.mongo, ctx.tenant, input.userID, input.avatar),
updateUserRole: async (input: GQLUpdateUserRoleInput) =>
@@ -145,6 +145,10 @@ export const Mutation: Required<GQLMutationTypeResolver<void>> = {
user: await ctx.mutators.Users.updateUserUsername(input),
clientMutationId: input.clientMutationId,
}),
updateEmail: async (source, { input }, ctx) => ({
user: await ctx.mutators.Users.updateEmail(input),
clientMutationId: input.clientMutationId,
}),
updateUserEmail: async (source, { input }, ctx) => ({
user: await ctx.mutators.Users.updateUserEmail(input),
clientMutationId: input.clientMutationId,
@@ -4189,6 +4189,38 @@ type UpdateUserUsernamePayload {
clientMutationId: String!
}
##################
# updateEmail
##################
input UpdateEmailInput {
"""
email is the email address to set for the User.
"""
email: String!
"""
password is the users password.
"""
password: String!
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
type UpdateEmailPayload {
"""
user is the possibly modified User.
"""
user: User!
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
##################
# updateUserEmail
##################
@@ -4704,6 +4736,12 @@ type Mutation {
input: UpdateUserUsernameInput!
): UpdateUserUsernamePayload! @auth(roles: [ADMIN])
"""
updateEmail allows administrators to update a given User's email address
to the one provided.
"""
updateEmail(input: UpdateEmailInput!): UpdateEmailPayload! @auth
"""
updateUserEmail allows administrators to update a given User's email address
to the one provided.