From 92f941a54c8bde45509213eb92f253c8b9688bf1 Mon Sep 17 00:00:00 2001 From: Jeremy Letto Date: Sun, 30 Jan 2022 22:06:30 -0600 Subject: [PATCH] renable login after fail attempt (#4552) Co-authored-by: Jeremy Letto --- webclient/src/containers/Login/Login.tsx | 4 ++++ webclient/src/forms/LoginForm/LoginForm.tsx | 2 -- webclient/src/store/server/server.actions.ts | 3 +++ webclient/src/store/server/server.dispatch.ts | 3 +++ webclient/src/store/server/server.types.ts | 1 + webclient/src/websocket/commands/SessionCommands.ts | 1 + webclient/src/websocket/persistence/SessionPersistence.ts | 4 ++++ 7 files changed, 16 insertions(+), 2 deletions(-) diff --git a/webclient/src/containers/Login/Login.tsx b/webclient/src/containers/Login/Login.tsx index 85c121be..dd50a788 100644 --- a/webclient/src/containers/Login/Login.tsx +++ b/webclient/src/containers/Login/Login.tsx @@ -87,6 +87,10 @@ const Login = ({ state, description }: LoginProps) => { openActivateAccountDialog(); }, ServerTypes.ACCOUNT_AWAITING_ACTIVATION, []); + useReduxEffect(() => { + resetSubmitButton(); + }, [ServerTypes.LOGIN_FAILED], []); + useReduxEffect(({ options: { hashedPassword } }) => { if (hostIdToRemember) { HostDTO.get(hostIdToRemember).then(host => { diff --git a/webclient/src/forms/LoginForm/LoginForm.tsx b/webclient/src/forms/LoginForm/LoginForm.tsx index 8218dc16..0f3779b5 100644 --- a/webclient/src/forms/LoginForm/LoginForm.tsx +++ b/webclient/src/forms/LoginForm/LoginForm.tsx @@ -41,8 +41,6 @@ const LoginForm = ({ onSubmit, disableSubmitButton, onResetPassword }: LoginForm setPasswordLabel(useStoredLabel ? STORED_PASSWORD_LABEL : PASSWORD_LABEL); }; - - return (
{({ handleSubmit, form }) => { diff --git a/webclient/src/store/server/server.actions.ts b/webclient/src/store/server/server.actions.ts index d1a3b2f4..3789d1e1 100644 --- a/webclient/src/store/server/server.actions.ts +++ b/webclient/src/store/server/server.actions.ts @@ -11,6 +11,9 @@ export const Actions = { type: Types.LOGIN_SUCCESSFUL, options }), + loginFailed: () => ({ + type: Types.LOGIN_FAILED, + }), connectionClosed: reason => ({ type: Types.CONNECTION_CLOSED, reason diff --git a/webclient/src/store/server/server.dispatch.ts b/webclient/src/store/server/server.dispatch.ts index a489edbc..581fe2ed 100644 --- a/webclient/src/store/server/server.dispatch.ts +++ b/webclient/src/store/server/server.dispatch.ts @@ -9,6 +9,9 @@ export const Dispatch = { loginSuccessful: options => { store.dispatch(Actions.loginSuccessful(options)); }, + loginFailed: () => { + store.dispatch(Actions.loginFailed()); + }, connectionClosed: reason => { store.dispatch(Actions.connectionClosed(reason)); }, diff --git a/webclient/src/store/server/server.types.ts b/webclient/src/store/server/server.types.ts index 5767c3a8..c797f365 100644 --- a/webclient/src/store/server/server.types.ts +++ b/webclient/src/store/server/server.types.ts @@ -1,6 +1,7 @@ export const Types = { CLEAR_STORE: '[Server] Clear Store', LOGIN_SUCCESSFUL: '[Server] Login Successful', + LOGIN_FAILED: '[Server] Login Failed', CONNECTION_CLOSED: '[Server] Connection Closed', SERVER_MESSAGE: '[Server] Server Message', UPDATE_BUDDY_LIST: '[Server] Update Buddy List', diff --git a/webclient/src/websocket/commands/SessionCommands.ts b/webclient/src/websocket/commands/SessionCommands.ts index 354d908a..281c6ebf 100644 --- a/webclient/src/websocket/commands/SessionCommands.ts +++ b/webclient/src/websocket/commands/SessionCommands.ts @@ -116,6 +116,7 @@ export class SessionCommands { SessionCommands.updateStatus(StatusEnum.DISCONNECTED, `Login failed: unknown error: ${raw.responseCode}`); } + SessionPersistence.loginFailed(); SessionCommands.disconnect(); }); } diff --git a/webclient/src/websocket/persistence/SessionPersistence.ts b/webclient/src/websocket/persistence/SessionPersistence.ts index 78e385a2..f168a868 100644 --- a/webclient/src/websocket/persistence/SessionPersistence.ts +++ b/webclient/src/websocket/persistence/SessionPersistence.ts @@ -13,6 +13,10 @@ export class SessionPersistence { ServerDispatch.loginSuccessful(options); } + static loginFailed() { + ServerDispatch.loginFailed(); + } + static connectionClosed(reason: number) { ServerDispatch.connectionClosed(reason); }