forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement new password verification flow front (RocketChat#29322)
- Loading branch information
1 parent
e1ab0da
commit 3f22ec2
Showing
16 changed files
with
282 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Box, Icon } from '@rocket.chat/fuselage'; | ||
import type { useVerifyPassword } from '@rocket.chat/ui-contexts'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
type PasswordVerifierProps = { | ||
password: string; | ||
passwordVerifications: ReturnType<typeof useVerifyPassword>; | ||
}; | ||
|
||
export const PasswordVerifier = ({ password, passwordVerifications }: PasswordVerifierProps) => { | ||
const { t } = useTranslation(); | ||
|
||
const handleRenderPasswordVerification = (passwordVerifications: ReturnType<typeof useVerifyPassword>) => { | ||
const verifications = []; | ||
|
||
if (!passwordVerifications) return null; | ||
|
||
for (const verification in passwordVerifications) { | ||
if (passwordVerifications[verification]) { | ||
const { isValid, limit } = passwordVerifications[verification]; | ||
verifications.push( | ||
<Box | ||
display='flex' | ||
flexBasis='50%' | ||
alignItems='center' | ||
mbe='x8' | ||
fontScale='c1' | ||
key={verification} | ||
color={isValid && password.length !== 0 ? 'status-font-on-success' : 'status-font-on-danger'} | ||
> | ||
<Icon | ||
name={isValid && password.length !== 0 ? 'success-circle' : 'error-circle'} | ||
color={isValid && password.length !== 0 ? 'status-font-on-success' : 'status-font-on-danger'} | ||
size='x16' | ||
mie='x4' | ||
/> | ||
{t(`${verification}-label`, { limit })} | ||
</Box>, | ||
); | ||
} | ||
} | ||
|
||
return verifications; | ||
}; | ||
|
||
return ( | ||
<Box display='flex' flexDirection='column' mbs='x8'> | ||
<Box mbe='x8' fontScale='c2'> | ||
{t('Password_must_have')} | ||
</Box> | ||
<Box display='flex' flexWrap='wrap'> | ||
{handleRenderPasswordVerification(passwordVerifications)} | ||
</Box> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { useEndpoint } from './useEndpoint'; | ||
|
||
export const usePasswordPolicy = () => { | ||
const getPasswordPolicy = useEndpoint('GET', '/v1/pw.getPolicy'); | ||
|
||
return useQuery(['login', 'password-policy'], async () => getPasswordPolicy()); | ||
}; |
Oops, something went wrong.