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

[DEV-1336] Fix change password page and changed password page #608

Merged
merged 45 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ec6ad0b
Fix sign-in and confirm sign-in UI and UX
marcobottaro Feb 5, 2024
4762a88
Add changeset
marcobottaro Feb 5, 2024
c60e89e
Fix sign-up and confirm sign-up UI and UX
marcobottaro Feb 5, 2024
d6d4272
Remove duplicated state constant
marcobottaro Feb 6, 2024
07605aa
Remove useless fragment
marcobottaro Feb 6, 2024
53fccf2
Rename constant and add an explicit cast to avoid a linting warning
marcobottaro Feb 6, 2024
e98c99e
Merge remote-tracking branch 'origin/DEV-1333-sign-in-and-confirm-sig…
marcobottaro Feb 6, 2024
a62fc31
test(DEV-1333): add auth helpers' tests
MikeAtUqido Feb 6, 2024
efafaad
Fix reset password request page UI and UX
marcobottaro Feb 6, 2024
6378f8e
Fix translations
marcobottaro Feb 6, 2024
a3b8615
Fix change password page UI and UX
marcobottaro Feb 6, 2024
7c690e7
Move ResentEmail component on bottom of the page
marcobottaro Feb 6, 2024
343fada
Add autoComplete param to textFields in LoginForm
marcobottaro Feb 6, 2024
ba27934
Add changeset
marcobottaro Feb 6, 2024
43235ea
Add changeset
marcobottaro Feb 6, 2024
d060a17
Merge branch 'DEV-1335-reset-passoword-request' into DEV-1336-change-…
tommaso1 Feb 8, 2024
0620ecf
Merge branch 'DEV-1333-sign-in-and-confirm-sign-in' into DEV-1334-sig…
tommaso1 Feb 8, 2024
962c8c4
Merge branch 'main' into DEV-1333-sign-in-and-confirm-sign-in
marcobottaro Feb 9, 2024
14aa71c
Merge branch 'main' into DEV-1333-sign-in-and-confirm-sign-in
marcobottaro Feb 13, 2024
629f80c
Add missing translation and remove unnecessary console.log
marcobottaro Feb 13, 2024
5bf746d
Merge remote-tracking branch 'origin/DEV-1333-sign-in-and-confirm-sig…
marcobottaro Feb 13, 2024
380ea56
Disable submit button on click while signing up
marcobottaro Feb 13, 2024
388ca7b
Merge branch 'DEV-1333-sign-in-and-confirm-sign-in' into DEV-1334-sig…
marcobottaro Feb 13, 2024
8c5d77f
Merge remote-tracking branch 'origin/DEV-1334-sign-up-and-confirm-sig…
marcobottaro Feb 13, 2024
62d8816
Disable submit button on click while asking for password reset
marcobottaro Feb 14, 2024
c39c8a5
Remove un unnecessary dependency from React Hook useCallback's depend…
marcobottaro Feb 14, 2024
83b5d8a
Merge remote-tracking branch 'origin/main' into DEV-1336-change-password
marcobottaro Feb 14, 2024
49ce793
Disable submit button on click while changing password
marcobottaro Feb 14, 2024
b797334
Merge remote-tracking branch 'origin/main' into DEV-1334-sign-up-and-…
marcobottaro Feb 14, 2024
65873d8
Merge remote-tracking branch 'origin/DEV-1335-reset-passoword-request…
marcobottaro Feb 14, 2024
138b082
Merge branch 'DEV-1334-sign-up-and-confirm-sign-up' into DEV-1335-res…
marcobottaro Feb 14, 2024
59ed2e6
Merge remote-tracking branch 'origin/DEV-1335-reset-passoword-request…
marcobottaro Feb 14, 2024
bac7c87
Catch missing Cognito error
marcobottaro Feb 15, 2024
ce442ee
Merge remote-tracking branch 'origin/main' into DEV-1336-change-password
marcobottaro Feb 15, 2024
d57a9c7
Remove ghost translations
marcobottaro Feb 15, 2024
cfe1f5e
Revert "Remove ghost translations"
marcobottaro Feb 15, 2024
01c243d
Update apps/nextjs-website/src/config.ts
MarcoPonchia Feb 15, 2024
ac52787
Delete .changeset/lazy-poets-melt.md
MarcoPonchia Feb 15, 2024
86c100d
Revert missing updated label after merge
MarcoPonchia Feb 15, 2024
eb56c96
Merge branch 'main' into DEV-1336-change-password
MarcoPonchia Feb 15, 2024
9873526
Merge branch 'main' into DEV-1336-change-password
kin0992 Feb 15, 2024
f8d85b4
Remove useless router replace
marcobottaro Feb 16, 2024
26de4e5
Update apps/nextjs-website/src/messages/it.json
marcobottaro Feb 16, 2024
e8474b3
Update apps/nextjs-website/src/messages/it.json
marcobottaro Feb 16, 2024
25ffc0a
Merge branch 'main' into DEV-1336-change-password
marcobottaro Feb 16, 2024
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
5 changes: 5 additions & 0 deletions .changeset/silly-lizards-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Fix change password page and changed password page
80 changes: 0 additions & 80 deletions apps/nextjs-website/src/_contents/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,61 +310,7 @@ export const translations = {
},
},
auth: {
login: {
action: 'Accedi',
loginToYourAccount: 'Accedi al tuo account DevPortal',
rememberMe: 'Ricordami',
forgotPassword: 'Hai dimenticato la password?',
noAccount: 'Non hai un account?',
},
confirmLogin: {
title: 'Verifica la tua identità',
body: (email: string) =>
`Abbiamo inviato un codice di verifica a ${email} Il codice scade tra 3 minuti.`,
code: 'Codice di verifica',
checkJunkMail:
'Non hai ricevuto alcuna email? Controlla la posta indesiderata oppure',
continue: 'Continua',
resendEmail: 'Reinvia email',
},
accountActivated: {
goToLogin: 'Vai al login',
welcomeMessage: 'Ti diamo il benvenuto su PagoPA DevPortal.',
yourAccountIsActive: 'Il tuo account è attivo',
},
signUp: {
action: 'Iscriviti',
createYourAccount: 'Crea il tuo account',
confirmComunications:
"Inviami e-mail relative alle risorse e agli aggiornamenti sui prodotti. Se questa casella è selezionata, PagoPA ti invierà di tanto in tanto delle e-mail utili e pertinenti. Puoi annullare l'iscrizione in qualsiasi momento.",
acceptPolicy1:
'Cliccando su iscriviti dichiari di aver preso visione della nostra ',
acceptPolicy2: 'privacy policy',
acceptPolicy3: ' e dei nostri ',
acceptPolicy4: "termini e condizioni d'uso",
alreadyHaveAnAccount: 'Hai già un account?',
whyCreateAccount: 'Perché iscriversi a PagoPA DevPortal',
passwordPolicy:
'Minimo 8 caratteri, almeno un numero, almeno una lettera maiuscola e almeno un carattere speciale',
emailSent: (email: string) => `Email inviata a ${email}`,
advantages: [
{
title: 'Accedi a contenuti esclusivi',
text: 'Assisti ai webinar di PagoPA e interagisci con noi sugli argomenti del momento.',
},
{
title: 'Ricevi aggiornamenti sui nostri prodotti',
text: "Non perdere neanche un nuovo contenuto, guida o tutorial. Puoi scegliere di ricevere via email le novità sui prodotti PagoPA e sull'integrazione tecnologica. ",
},
{
title: 'Accedi ai tool per velocizzare i tuoi sviluppi (in arrivo)',
text: 'Sblocca tutto il potenziale del DevPortal con API Key, Mocker, SDK ed altro ancora.',
},
{
title: 'Richiedi assistenza su un canale dedicato (in arrivo)',
text: 'Avvicinati con facilità alle soluzioni di cui hai bisogno e risolvi le difficoltà con il nostro aiuto.',
},
],
companyRoles: [
{ title: 'Ente pubblico', value: 'public-authority' },
{ title: 'Partner tecnologico', value: 'tech-partner' },
Expand All @@ -377,31 +323,5 @@ export const translations = {
{ title: 'Altro', value: 'other' },
],
},
confirmSignUp: {
confirmSignUp: 'Conferma che sei tu',
description: (email: string) =>
`Abbiamo inviato una e-mail a ${email}. Clicca sul bottone contenuto al suo interno per verificarla.`,
didntReceiveEmail:
"Non hai ricevuto l'e-mail? Controlla se nella posta indesiderata oppure",
resendEmail: 'Reinvia email',
wrongEmail: "L'indirizzo email è errato?",
},
resetPassword: {
title: 'Recupera password',
body: 'Inserisci il tuo indirizzo e-mail e ti invieremo le istruzioni per impostare una nuova password.',
goBackToLogin: 'Torna al login',
send: 'Invia',
checkEmailTitle: "Controlla l'email",
checkEmail: (email: string) =>
`Se esiste un account associato a ${email}, riceverai una e-mail con un link per impostare una nuova password.`,
resendEmailPrompt:
"Non hai ricevuto l'email? Controlla nella posta indesiderata oppure",
resendEmail: 'Reinvia email',
wrongEmail: "L'indirizzo e-mail è errato?",
passwordSet: 'Password impostata correttamente',
newPassword: 'Imposta una nuova password',
rememberPassword: 'Ricordi la tua password?',
invalidLinkError: 'Il link non è valido',
},
},
};
78 changes: 37 additions & 41 deletions apps/nextjs-website/src/app/auth/change-password/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
'use client';
import { Alert, Box, Grid, Snackbar } from '@mui/material';
import { Grid } from '@mui/material';
import PasswordChangedCard from '@/components/organisms/Auth/PasswordChangedCard';
import ChangePasswordForm from '@/components/organisms/Auth/ChangePasswordForm';
import { ResetPasswordSteps } from '@/lib/types/resetPasswordSteps';
import { useCallback, useState, useEffect } from 'react';
import { useSearchParams } from 'next/navigation';
import { Auth } from 'aws-amplify';
import PageNotFound from '@/app/not-found';
import { translations } from '@/_contents/translations';
import { snackbarAutoHideDurationMs } from '@/config';
import { useTranslations } from 'next-intl';
import Spinner from '@/components/atoms/Spinner/Spinner';
import PageBackgroundWrapper from '@/components/atoms/PageBackgroundWrapper/PageBackgroundWrapper';
import SingleCard from '@/components/atoms/SingleCard/SingleCard';
import { IllusError } from '@pagopa/mui-italia/dist/illustrations/Error';

enum State {
loading = 'loading',
error = 'error',
errorLink = 'errorLink',
success = 'success',
}

const ChangePassword = () => {
const {
auth: { resetPassword },
} = translations;
const confirmation = useTranslations('auth.confirmation');

const searchParams = useSearchParams();
const username = searchParams.get('username') || '';
const code = searchParams.get('code') || '';
Expand All @@ -22,16 +31,15 @@ const ChangePassword = () => {
ResetPasswordSteps.CHANGE_PASSWORD
);
const [password, setPassword] = useState('');
const [error, setError] = useState<string | null>(null);
const [isValidLink, setIsValidLink] = useState(false);
const [state, setState] = useState<State>(State.loading);

const onChangePassword = useCallback(async () => {
const success = await Auth.forgotPasswordSubmit(
username,
code,
password
).catch((err) => {
setError(err.message);
).catch(() => {
setState(State.errorLink);
return false;
});

Expand All @@ -42,28 +50,24 @@ const ChangePassword = () => {

useEffect(() => {
if (username != '' && code != '') {
setIsValidLink(true);
setState(State.success);
} else {
setError(resetPassword.invalidLinkError);
setState(State.errorLink);
}
}, []);

return (
<>
{isValidLink ? (
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '100vw',
minHeight: '70vh',
backgroundImage: 'url(/images/hero.jpg)',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: 'bottom right',
}}
>
switch (state) {
case State.error:
return <PageNotFound />;
case State.errorLink:
return (
<PageBackgroundWrapper>
<SingleCard icon={<IllusError />} title={confirmation('title')} />
</PageBackgroundWrapper>
);
case State.success:
return (
<PageBackgroundWrapper>
<Grid
container
justifyContent='center'
Expand All @@ -80,19 +84,11 @@ const ChangePassword = () => {
<PasswordChangedCard />
)}
</Grid>
</Box>
) : (
<PageNotFound />
)}
<Snackbar
open={!!error}
autoHideDuration={snackbarAutoHideDurationMs}
onClose={() => setError(null)}
>
<Alert severity={'error'}>{error}</Alert>
</Snackbar>
</>
);
</PageBackgroundWrapper>
);
default:
return <Spinner />;
}
};

export default ChangePassword;
15 changes: 14 additions & 1 deletion apps/nextjs-website/src/app/auth/confirmation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import PageBackgroundWrapper from '@/components/atoms/PageBackgroundWrapper/Page
import SingleCard from '@/components/atoms/SingleCard/SingleCard';
import { isProduction } from '@/config';
import { IllusError } from '@pagopa/mui-italia';
import AccountAlreadyConfirmed from '@/components/organisms/Auth/AccountAlreadyConfirmed';

enum State {
loading = 'loading',
resendCode = 'resendCode',
alreadyConfirmed = 'alreadyConfirmed',
error = 'error',
}

Expand All @@ -38,7 +40,16 @@ const Confirmation = () => {
// TODO: remove console warn and handle errors: [CodeMismatchException, ExpiredCodeException, InternalErrorException, LimitExceededException]
// see apps/nextjs-website/src/app/auth/email-confirmation/page.tsx
!isProduction && console.warn(error);
setState(State.resendCode);
switch (error.code) {
case 'AliasExistsException':
setState(State.alreadyConfirmed);
break;
case 'LimitExceededException':
setState(State.error);
break;
default:
setState(State.resendCode);
}
});
} else {
setState(State.error);
Expand All @@ -63,6 +74,8 @@ const Confirmation = () => {
switch (state) {
case State.error:
return <PageNotFound />;
case State.alreadyConfirmed:
return <AccountAlreadyConfirmed />;
case State.resendCode:
return (
<PageBackgroundWrapper>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import PageBackgroundWrapper from '@/components/atoms/PageBackgroundWrapper/PageBackgroundWrapper';
import SingleCard from '@/components/atoms/SingleCard/SingleCard';
import { Button } from '@mui/material';
import { IllusError } from '@pagopa/mui-italia';
import { useTranslations } from 'next-intl';
import Link from 'next/link';

const AccountAlreadyConfirmed = () => {
const accountAlreadyConfirmed = useTranslations(
'auth.login.accountAlreadyConfirmed'
);
return (
<PageBackgroundWrapper>
<SingleCard
icon={<IllusError />}
title={accountAlreadyConfirmed('yourAccountIsAlreadyConfirmed')}
cta={
<Button
component={Link}
disabled={false}
variant='contained'
href='auth/login'
>
{accountAlreadyConfirmed('goToLogin')}
</Button>
}
/>
</PageBackgroundWrapper>
);
};
export default AccountAlreadyConfirmed;
Loading
Loading