-
Notifications
You must be signed in to change notification settings - Fork 10
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: verify email warning #1458
base: master
Are you sure you want to change the base?
Conversation
🚀 Deployed on https://pr-1458--dhis2-user-profile.netlify.app |
const VerifyEmailWarning = () => { | ||
const { data: userData, error: userError } = | ||
useDataQuery(getUserProfileQuery) | ||
const { data: systemData, error: systemError } = useDataQuery( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried getting the enforceVerifiedEmail
state from the systemInfo
object directly from useConfig
but couldn't, hence the api call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may also be added into the user profile details page as well. open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Chisomchima: looks pretty good.
- The app already has some logic for retrieving systemSettings and api/me (see https://github.com/dhis2/user-profile-app/blob/master/src/AppWrapper.js). It would be better to modify/reuse those stores if possible so that we don't have to remake similar requests (also so the logic can be in one place).
- I think you're missing one requirement from the ticket:
when a system has the "enforce verified emails" setting and user has NOT verified their email*, if a user visits the user profile app, they are directed to user profile page
. Right now if I just visit the main page of the app with a user with unverified email, I get directed to theviewProfile
page, but I should be sent toprofile
page in this case, so that I see the warning message. I assume you can edit the logic in app.router.js because it's a child component of the AppWrapper, so the settings/me information should be available here. If it's not possible for some reason, I think it's probably better to change the default routing of the app - can you add a margin on the NoticeBox warning, so that there's not the overhang that we currently have:
systemData?.systemSettings?.enforceVerifiedEmail | ||
const emailVerified = userData?.me?.emailVerified | ||
|
||
if (userError || systemError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better as a NoticeBox if we're going to show an error about not retrieving information (e.g. like we have elsewhere in the app:
user-profile-app/src/personalAccessTokens/generateTokenModal/AuthoritiesWarning.component.js
Lines 27 to 39 in e920781
if (error) { | |
return ( | |
<NoticeBox | |
className={styles.noticeBox} | |
error | |
title={i18n.t('Error fetching your authorities')} | |
> | |
<Button onClick={refetch}> | |
{i18n.t('Retry loading authorities')} | |
</Button> | |
</NoticeBox> | |
) | |
} |
However, I think if these requests were going to fail, the app seems like it wouldn't have loaded (
user-profile-app/src/AppWrapper.js
Lines 71 to 73 in e920781
(error) => { | |
log.error('Failed to load user settings:', error) | |
} |
Implements DHIS2-18376
Description
This PR introduces a new feature to prompt users to verify their email address when the "Enforce Verified Emails" setting is enabled for the organization. The feature checks if the email verification setting is enabled (enforceVerifiedEmail), and whether the user has verified their email (emailVerified). If the email is not verified, a warning will be shown at the top of the user profile page, prompting the user to verify their email. The user can still continue using the system without email verification, but the warning will remain visible until their email is verified.
Checklist
The warning message is displayed inside a NoticeBox component at the top of the user profile page. It will show the following message when the user's email is not verified:
"Your email is not verified. Please verify your email to continue using the system."
Screenshots