diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index c95e958..91644de 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -22,6 +22,7 @@ "Password": "Password", "Label": "Login", "ChangeUser": "Change user", + "UserChanged": "User changed", "Logout": "Logout", "IncorrectCredentials": "Incorrect credentials.", "Hello": "Hi, {{username}}", diff --git a/public/locales/ro/translations.json b/public/locales/ro/translations.json index b307523..b1753ae 100644 --- a/public/locales/ro/translations.json +++ b/public/locales/ro/translations.json @@ -13,6 +13,7 @@ "Password": "Parolă", "Label": "Autentificare", "ChangeUser": "Schimbă utilizatorul", + "UserChanged": "Utilizator schimbat", "Logout": "Deconectare", "IncorrectCredentials": "Credențiale incorecte.", "Hello": "Salut, {{username}}", diff --git a/src/features/login/components/LoggedInComponent.js b/src/features/login/components/LoggedInComponent.js index 1f82e4c..29369dc 100644 --- a/src/features/login/components/LoggedInComponent.js +++ b/src/features/login/components/LoggedInComponent.js @@ -16,6 +16,7 @@ import { import { AccountBox, RotateLeft, ExitToApp } from "@material-ui/icons"; import LoginComponent from "./LoginComponent"; import { useTranslation } from "react-i18next"; +import { useToast } from "../../../hooks"; const useStyles = makeStyles(theme => ({ card: { @@ -42,6 +43,7 @@ const LoggedInComponent = ({ const classes = useStyles(); const { t } = useTranslation(); const [expanded, setExpanded] = useState(false); + const { info } = useToast(); const handleExpandLogin = () => { setExpanded(!expanded); @@ -58,6 +60,14 @@ const LoggedInComponent = ({ return "N/A"; }, [token, t]); + const handleLogin = async () => { + const result = await onLogin(); + if (result) { + setExpanded(false); + info(t("Login.UserChanged")); + } + }; + return ( diff --git a/src/features/login/components/LoginContainer.js b/src/features/login/components/LoginContainer.js index a7721b4..08e13d5 100644 --- a/src/features/login/components/LoginContainer.js +++ b/src/features/login/components/LoginContainer.js @@ -27,6 +27,7 @@ const LoginContainer = () => { const response = await authenticate(userName, password); if (response.status === "SUCCESS") { dispatchActions.onAuthorizationTokenChange(response.token); + return response.token; } else if (response.status === "BAD_CREDENTIALS") { error(t("Login.IncorrectCredentials")); }