Skip to content

Commit

Permalink
[feature] Added support for password expiration feature #713
Browse files Browse the repository at this point in the history
Closes #713
  • Loading branch information
pandafy committed Nov 6, 2023
1 parent 737aef5 commit cecc6c4
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 17 deletions.
28 changes: 13 additions & 15 deletions client/components/password-change/password-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,12 @@ export default class PasswordChange extends React.Component {

async componentDidMount() {
const {setLoading} = this.context;
const {
setTitle,
orgName,
cookies,
userData,
setUserData,
logout,
orgSlug,
language,
} = this.props;
const {setTitle, orgName, cookies, setUserData, logout, orgSlug, language} =
this.props;
let {userData} = this.props;
setLoading(true);
setTitle(t`PWD_CHANGE_TITL`, orgName);
const {mustLogin, mustLogout, repeatLogin} = userData;
await validateToken(
cookies,
orgSlug,
Expand All @@ -59,6 +53,8 @@ export default class PasswordChange extends React.Component {
logout,
language,
);
({userData} = this.props);
setUserData({...userData, mustLogin, mustLogout, repeatLogin});
setLoading(false);
}

Expand Down Expand Up @@ -224,11 +220,13 @@ export default class PasswordChange extends React.Component {
/>
</div>

<div className="row cancel">
<Link className="button full" to={`/${orgSlug}/status`}>
{t`CANCEL`}
</Link>
</div>
{userData.password_expired !== true && (
<div className="row cancel">
<Link className="button full" to={`/${orgSlug}/status`}>
{t`CANCEL`}
</Link>
</div>
)}
</div>
</form>

Expand Down
12 changes: 11 additions & 1 deletion client/components/status/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default class Status extends React.Component {
setTitle,
orgName,
language,
navigate,
} = this.props;
setTitle(t`STATUS_TITL`, orgName);
const {setLoading} = this.context;
Expand Down Expand Up @@ -114,7 +115,16 @@ export default class Status extends React.Component {

const {mustLogin, mustLogout, repeatLogin} = userData;
({userData} = this.props);

if (userData.password_expired === true) {
toast.warning(t`PASSWORD_EXPIRED`);
setUserData({
...userData,
mustLogin,
mustLogout,
repeatLogin,
});
navigate(`/${orgSlug}/change-password`);
}
const {
radius_user_token: password,
username,
Expand Down
4 changes: 3 additions & 1 deletion client/utils/validate-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const validateToken = async (
// or payment_url of user is undefined
if (
userData &&
((token && userData.radius_user_token === undefined) ||
((token &&
(userData.radius_user_token === undefined ||
userData.password_expired === true)) ||
(userData.method === "bank_card" &&
userData.is_verified !== true &&
!userData.payment_url))
Expand Down
4 changes: 4 additions & 0 deletions i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ msgstr "Es ist ein Fehler aufgetreten!"
msgid "LOGOUT_SUCCESS"
msgstr "Logout war erfolgreich"

#: client/components/status/status.js:119
msgid "PASSWORD_EXPIRED"
msgstr "Ihr Passwort ist abgelaufen, bitte ändern Sie Ihr Passwort."

#: client/components/status/status.js:467
#: client/components/status/status.js:658
msgid "ACCT_ACTIVE"
Expand Down
4 changes: 4 additions & 0 deletions i18n/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ msgstr "Login successful"
msgid "LOGOUT_SUCCESS"
msgstr "Logout successful"

#: client/components/status/status.js:119
msgid "PASSWORD_EXPIRED"
msgstr "Your password has expired, please change your password."

#: client/components/password-change/password-change.js:101
#: client/components/password-change/password-change.js:109
#: client/components/password-change/password-change.test.js:129
Expand Down
4 changes: 4 additions & 0 deletions i18n/fur.po
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ msgstr "Al è capitât un erôr!"
msgid "LOGOUT_SUCCESS"
msgstr "Logout fat cun sucès"

#: client/components/status/status.js:119
msgid "PASSWORD_EXPIRED"
msgstr "La tua password è scaduta, modifica la password."

#: client/components/password-change/password-change.js:61
#: client/components/password-change/password-change.test.js:115
#: client/components/password-change/password-change.test.js:120
Expand Down
4 changes: 4 additions & 0 deletions i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ msgstr "Si è verificato un errore!"
msgid "LOGOUT_SUCCESS"
msgstr "Log out effettuato con successo"

#: client/components/status/status.js:119
msgid "PASSWORD_EXPIRED"
msgstr "La tua password è scaduta, modifica la password."

#: client/components/password-change/password-change.js:61
#: client/components/password-change/password-change.test.js:115
#: client/components/password-change/password-change.test.js:120
Expand Down
4 changes: 4 additions & 0 deletions i18n/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ msgstr "Была ошибка!"
msgid "LOGOUT_SUCCESS"
msgstr "Успешный выход"

#: client/components/status/status.js:119
msgid "PASSWORD_EXPIRED"
msgstr "Срок действия вашего пароля истек, пожалуйста, измените пароль."

#: client/components/password-change/password-change.js:61
#: client/components/password-change/password-change.test.js:115
#: client/components/password-change/password-change.test.js:120
Expand Down
4 changes: 4 additions & 0 deletions i18n/sl.po
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ msgstr "Prijava je bila uspešna"
msgid "LOGOUT_SUCCESS"
msgstr "Odjava je bila uspešna"

#: client/components/status/status.js:119
msgid "PASSWORD_EXPIRED"
msgstr "Vaše geslo je poteklo, spremenite geslo."

#: client/components/password-change/password-change.js:87
#: client/components/password-change/password-change.js:93
#: client/components/password-change/password-change.test.js:129
Expand Down

0 comments on commit cecc6c4

Please sign in to comment.