Skip to content
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

feat: add message when email not set or not activated, allow triggering a new activation email, store new email separately from activated one #4250

Draft
wants to merge 2 commits into
base: v3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions apps/frontend-pwa/src/components/forms/UpdateAccountInfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import {
CheckParticipantNameAvailableDocument,
Participant,
RequestActivationEmailDocument,
UpdateParticipantProfileDocument,
} from '@klicker-uzh/graphql/dist/ops'
import DebouncedUsernameField from '@klicker-uzh/shared-components/src/DebouncedUsernameField'
Expand Down Expand Up @@ -43,6 +44,8 @@ function UpdateAccountInfoForm({
boolean | undefined
>(true)

const [requestActivationEmail] = useMutation(RequestActivationEmailDocument)

return (
<Formik
validationSchema={yup.object({
Expand Down Expand Up @@ -133,12 +136,10 @@ function UpdateAccountInfoForm({
) : null}
<div className="mb-2 space-y-3">
<FormikTextField
// TODO: as soon as verification mechanism for email is implemented, add check for "isEmailValid" in DB for disabled field as emails with typos cannot be changed currently
disabled={
user?.email !== '' &&
user?.email !== null &&
typeof user?.email !== 'undefined' &&
!!values.email
user?.isSSOAccount &&
typeof user.email === 'string' &&
user.email !== ''
}
name="email"
label={t('shared.generic.email')}
Expand All @@ -147,6 +148,17 @@ function UpdateAccountInfoForm({
}}
data={{ cy: 'update-account-email' }}
/>
{!user.isEmailValid && (
<div>
{t.rich('pwa.profile.emailInactive', {
button: (
<Button onClick={() => requestActivationEmail()}>
here
</Button>
),
})}
</div>
)}
<DebouncedUsernameField
t={t}
name="username"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mutation RequestActivationEmail {
requestActivationEmail
}
2 changes: 2 additions & 0 deletions packages/graphql/src/graphql/ops/QSelf.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ query Self {
avatarSettings
isActive
isProfilePublic
isSSOAccount
isEmailValid
xp
level
levelData {
Expand Down
36 changes: 36 additions & 0 deletions packages/graphql/src/ops.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10897,6 +10897,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "requestActivationEmail",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "requestMigrationToken",
"description": null,
Expand Down Expand Up @@ -12977,6 +12989,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isEmailValid",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isProfilePublic",
"description": null,
Expand All @@ -12989,6 +13013,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isSSOAccount",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isSelf",
"description": null,
Expand Down
13 changes: 11 additions & 2 deletions packages/graphql/src/ops.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/graphql/src/public/client.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"PublishScheduledPracticeQuizzes": "00c2398a3fc6f182c85f064913a7f43bddbd21762b827ade88b446bcef5e3c12",
"RateElement": "9fa091063d34571e1c5880e6f0c1ef1c2c6267b29fefe3ac8f23c0185a8c34b5",
"RenameParticipantGroup": "e909972c210ced0bff2f94496e2f71d87e9514f5b01e61eca0b66327d843af8a",
"RequestActivationEmail": "e9733e54d0b854512cb240d8ac7b56558ea5ce31d40f01080d6268a82e6b461c",
"RequestMigrationToken": "27743950d25589484d14d9b19d39130a63085a49820d77e91ad9365096c4423d",
"ResolveFeedback": "1462d426a28839917a0651fdb669bea4fa1962e61b375a627f210c618dafbf4d",
"RespondToElementStack": "21e8c6b99c053fcdc346553a5a42c2c4ac63d6ca6c3e00348bbb2166a0a94133",
Expand Down Expand Up @@ -145,7 +146,7 @@
"GetUserTags": "cfc63cede68a95d79f5fe5a79c7f6275abae9c47b25fcfc665cc8d3e00bac3db",
"GroupActivityDetails": "12eef1f0023e24aa29fe3a088aa89000984c03a73c58a71380e783a73a9262a5",
"Participations": "76ac5a5c539e57e395109b5836a055573e43fb4b2e4ba6ab3b1374da8580d5c6",
"Self": "05603b4fdfd68bbe0990c57cb9e59a5f71ef9705d23d928fd63589dd5364f945",
"Self": "eead3dc674b9d8bfca49e21943ddad5f171a9f02604e9627e3a52acc5577e691",
"SelfWithAchievements": "f161d562f384a81dbecd1baa222201522702925a82f859a1238038fbd35413fb",
"UserProfile": "d37d1882bef914e250cba85de86301e48ed8fca440cde15f3568320219b11e1c",
"FeedbackAdded": "b7948b93f7418778d06c2b3a18d84b3a46c071d3beb1c539aa15d727d327c264",
Expand Down
3 changes: 3 additions & 0 deletions packages/graphql/src/public/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ type Mutation {
publishScheduledPracticeQuizzes: Boolean!
rateElement(elementId: Int!, elementInstanceId: Int!, rating: Int!): ElementFeedback
renameParticipantGroup(groupId: String!, name: String!): ParticipantGroup
requestActivationEmail: Boolean
requestMigrationToken(email: String!): Boolean
resolveFeedback(id: Int!, isResolved: Boolean!): Feedback
respondToElementStack(courseId: String!, responses: [StackResponseInput!]!, stackAnswerTime: Int!, stackId: Int!): StackFeedback
Expand Down Expand Up @@ -804,7 +805,9 @@ type Participant {
email: String
id: ID!
isActive: Boolean!
isEmailValid: Boolean
isProfilePublic: Boolean
isSSOAccount: Boolean
isSelf: Boolean
lastLoginAt: Date
level: Int
Expand Down
3 changes: 2 additions & 1 deletion packages/graphql/src/public/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"00c2398a3fc6f182c85f064913a7f43bddbd21762b827ade88b446bcef5e3c12": "mutation PublishScheduledPracticeQuizzes {\n publishScheduledPracticeQuizzes\n}",
"9fa091063d34571e1c5880e6f0c1ef1c2c6267b29fefe3ac8f23c0185a8c34b5": "mutation RateElement($elementInstanceId: Int!, $elementId: Int!, $rating: Int!) {\n rateElement(elementInstanceId: $elementInstanceId, elementId: $elementId, rating: $rating) {\n id\n upvote\n downvote\n feedback\n __typename\n }\n}",
"e909972c210ced0bff2f94496e2f71d87e9514f5b01e61eca0b66327d843af8a": "mutation RenameParticipantGroup($groupId: String!, $name: String!) {\n renameParticipantGroup(groupId: $groupId, name: $name) {\n id\n name\n __typename\n }\n}",
"e9733e54d0b854512cb240d8ac7b56558ea5ce31d40f01080d6268a82e6b461c": "mutation RequestActivationEmail {\n requestActivationEmail\n}",
"27743950d25589484d14d9b19d39130a63085a49820d77e91ad9365096c4423d": "mutation RequestMigrationToken($email: String!) {\n requestMigrationToken(email: $email)\n}",
"1462d426a28839917a0651fdb669bea4fa1962e61b375a627f210c618dafbf4d": "mutation ResolveFeedback($id: Int!, $isResolved: Boolean!) {\n resolveFeedback(id: $id, isResolved: $isResolved) {\n id\n isPublished\n isPinned\n isResolved\n content\n votes\n __typename\n }\n}",
"21e8c6b99c053fcdc346553a5a42c2c4ac63d6ca6c3e00348bbb2166a0a94133": "mutation RespondToElementStack($stackId: Int!, $courseId: String!, $responses: [StackResponseInput!]!, $stackAnswerTime: Int!) {\n respondToElementStack(stackId: $stackId, courseId: $courseId, responses: $responses, stackAnswerTime: $stackAnswerTime) {\n id\n status\n score\n evaluations {\n instanceId\n pointsMultiplier\n explanation\n feedbacks {\n ix\n feedback\n correct\n value\n __typename\n }\n choices\n numAnswers\n answers\n score\n pointsAwarded\n percentile\n newPointsFrom\n xpAwarded\n newXpFrom\n solutions\n solutionRanges\n __typename\n }\n __typename\n }\n}",
Expand Down Expand Up @@ -145,7 +146,7 @@
"cfc63cede68a95d79f5fe5a79c7f6275abae9c47b25fcfc665cc8d3e00bac3db": "query GetUserTags {\n userTags {\n id\n name\n order\n __typename\n }\n}",
"12eef1f0023e24aa29fe3a088aa89000984c03a73c58a71380e783a73a9262a5": "fragment ElementDataWithoutSolutions on ElementInstance {\n elementData {\n id\n elementId\n name\n type\n content\n explanation\n ... on ChoicesElementData {\n options {\n displayMode\n choices {\n ix\n value\n __typename\n }\n __typename\n }\n __typename\n }\n ... on NumericalElementData {\n options {\n accuracy\n placeholder\n unit\n restrictions {\n min\n max\n __typename\n }\n __typename\n }\n __typename\n }\n ... on FreeTextElementData {\n options {\n restrictions {\n maxLength\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n}\nquery GroupActivityDetails($activityId: String!, $groupId: String!) {\n groupActivityDetails(activityId: $activityId, groupId: $groupId) {\n id\n displayName\n description\n scheduledStartAt\n scheduledEndAt\n clues {\n id\n displayName\n __typename\n }\n stacks {\n id\n type\n displayName\n description\n order\n elements {\n id\n type\n elementType\n ...ElementDataWithoutSolutions\n __typename\n }\n __typename\n }\n course {\n id\n displayName\n color\n __typename\n }\n group {\n id\n name\n participants {\n id\n username\n avatar\n isSelf\n __typename\n }\n __typename\n }\n activityInstance {\n id\n clues {\n id\n displayName\n type\n unit\n value\n participant {\n id\n username\n avatar\n isSelf\n __typename\n }\n __typename\n }\n decisions\n decisionsSubmittedAt\n results\n resultsComputedAt\n __typename\n }\n __typename\n }\n}",
"76ac5a5c539e57e395109b5836a055573e43fb4b2e4ba6ab3b1374da8580d5c6": "query Participations($endpoint: String) {\n participations(endpoint: $endpoint) {\n id\n completedMicroLearnings\n subscriptions {\n id\n endpoint\n __typename\n }\n course {\n id\n displayName\n startDate\n endDate\n description\n isGamificationEnabled\n microLearnings {\n id\n displayName\n scheduledStartAt\n scheduledEndAt\n __typename\n }\n sessions {\n id\n displayName\n linkTo\n __typename\n }\n __typename\n }\n __typename\n }\n}",
"05603b4fdfd68bbe0990c57cb9e59a5f71ef9705d23d928fd63589dd5364f945": "query Self {\n self {\n id\n email\n username\n avatar\n avatarSettings\n isActive\n isProfilePublic\n xp\n level\n levelData {\n id\n index\n name\n avatar\n requiredXp\n nextLevel {\n id\n index\n requiredXp\n avatar\n name\n __typename\n }\n __typename\n }\n __typename\n }\n}",
"eead3dc674b9d8bfca49e21943ddad5f171a9f02604e9627e3a52acc5577e691": "query Self {\n self {\n id\n email\n username\n avatar\n avatarSettings\n isActive\n isProfilePublic\n isSSOAccount\n isEmailValid\n xp\n level\n levelData {\n id\n index\n name\n avatar\n requiredXp\n nextLevel {\n id\n index\n requiredXp\n avatar\n name\n __typename\n }\n __typename\n }\n __typename\n }\n}",
"f161d562f384a81dbecd1baa222201522702925a82f859a1238038fbd35413fb": "query SelfWithAchievements {\n selfWithAchievements {\n participant {\n id\n username\n avatar\n avatarSettings\n xp\n level\n levelData {\n id\n index\n name\n avatar\n requiredXp\n nextLevel {\n id\n index\n requiredXp\n avatar\n name\n __typename\n }\n __typename\n }\n achievements {\n id\n achievedAt\n achievedCount\n achievement {\n id\n nameDE\n nameEN\n descriptionDE\n descriptionEN\n icon\n iconColor\n __typename\n }\n __typename\n }\n __typename\n }\n achievements {\n id\n nameDE\n nameEN\n descriptionDE\n descriptionEN\n icon\n iconColor\n __typename\n }\n __typename\n }\n}",
"d37d1882bef914e250cba85de86301e48ed8fca440cde15f3568320219b11e1c": "query UserProfile {\n userProfile {\n id\n email\n sendProjectUpdates\n shortname\n locale\n firstLogin\n catalyst\n catalystTier\n __typename\n }\n}",
"b7948b93f7418778d06c2b3a18d84b3a46c071d3beb1c539aa15d727d327c264": "fragment FeedbackData on Feedback {\n id\n isPublished\n isPinned\n isResolved\n content\n votes\n resolvedAt\n createdAt\n responses {\n id\n content\n positiveReactions\n negativeReactions\n __typename\n }\n __typename\n}\nsubscription FeedbackAdded($sessionId: String!) {\n feedbackAdded(sessionId: $sessionId) {\n ...FeedbackData\n __typename\n }\n}",
Expand Down
7 changes: 7 additions & 0 deletions packages/graphql/src/schema/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ export const Mutation = builder.mutationType({

// ----- PARTICIPANT OPERATIONS
// #region
requestActivationEmail: t.withAuth(asParticipant).boolean({
nullable: true,
resolve(_, args, ctx) {
return AccountService.requestActivationEmail(args, ctx)
},
}),

joinCourse: t.withAuth(asParticipant).field({
nullable: true,
type: ParticipantLearningData,
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql/src/schema/participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export const Participant = ParticipantRef.implement({
username: t.exposeString('username', { nullable: false }),
isActive: t.exposeBoolean('isActive', { nullable: false }),
isProfilePublic: t.exposeBoolean('isProfilePublic', { nullable: true }),
isSSOAccount: t.exposeBoolean('isSSOAccount', { nullable: true }),
isEmailValid: t.exposeBoolean('isEmailValid', { nullable: true }),
avatar: t.exposeString('avatar', { nullable: true }),
avatarSettings: t.expose('avatarSettings', {
type: 'Json',
Expand Down
Loading
Loading