mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-19 13:23:55 -07:00
Support password reset workflow on Webatrice (#4445)
* Support password reset workflow. Also fix issue where a user would be disconnected "randomly" if they had a failed login, then successful one. Refactored a bit on Status Labels since they weren't really necessary and added complexity. * Disconnect in default cases where we don't know what to do, but shouldn't stay connected to the server
This commit is contained in:
parent
013bb8269f
commit
ac300b0b6d
10 changed files with 189 additions and 77 deletions
|
|
@ -300,7 +300,7 @@ describe('SessionEvents', () => {
|
|||
event(data);
|
||||
|
||||
expect(SessionPersistence.updateInfo).toHaveBeenCalledWith(data.serverName, data.serverVersion);
|
||||
expect(SessionCommands.updateStatus).toHaveBeenCalledWith(StatusEnum.LOGGINGIN, expect.any(String));
|
||||
expect(SessionCommands.updateStatus).toHaveBeenCalledWith(StatusEnum.LOGGING_IN, expect.any(String));
|
||||
expect(SessionCommands.login).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
@ -312,7 +312,6 @@ describe('SessionEvents', () => {
|
|||
event(data);
|
||||
|
||||
expect(SessionPersistence.updateInfo).toHaveBeenCalledWith(data.serverName, data.serverVersion);
|
||||
expect(SessionCommands.updateStatus).toHaveBeenCalledWith(StatusEnum.REGISTERING, expect.any(String));
|
||||
expect(SessionCommands.register).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
@ -324,7 +323,6 @@ describe('SessionEvents', () => {
|
|||
event(data);
|
||||
|
||||
expect(SessionPersistence.updateInfo).toHaveBeenCalledWith(data.serverName, data.serverVersion);
|
||||
expect(SessionCommands.updateStatus).toHaveBeenCalledWith(StatusEnum.ACTIVATING_ACCOUNT, expect.any(String));
|
||||
expect(SessionCommands.activateAccount).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function addToList({ listName, userInfo}: AddToListData) {
|
|||
}
|
||||
|
||||
function connectionClosed({ reason, reasonStr }: ConnectionClosedData) {
|
||||
let message = '';
|
||||
let message;
|
||||
|
||||
// @TODO (5)
|
||||
if (reasonStr) {
|
||||
|
|
@ -116,29 +116,34 @@ function serverIdentification(info: ServerIdentificationData) {
|
|||
const { serverName, serverVersion, protocolVersion } = info;
|
||||
|
||||
if (protocolVersion !== webClient.protocolVersion) {
|
||||
SessionCommands.disconnect();
|
||||
SessionCommands.updateStatus(StatusEnum.DISCONNECTED, `Protocol version mismatch: ${protocolVersion}`);
|
||||
SessionCommands.disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (webClient.options.reason) {
|
||||
case WebSocketConnectReason.LOGIN:
|
||||
SessionCommands.updateStatus(StatusEnum.LOGGINGIN, 'Logging in...');
|
||||
SessionCommands.updateStatus(StatusEnum.LOGGING_IN, 'Logging In...');
|
||||
SessionCommands.login();
|
||||
break;
|
||||
case WebSocketConnectReason.REGISTER:
|
||||
SessionCommands.updateStatus(StatusEnum.REGISTERING, 'Registering...');
|
||||
SessionCommands.register();
|
||||
break;
|
||||
case WebSocketConnectReason.ACTIVATE_ACCOUNT:
|
||||
SessionCommands.updateStatus(StatusEnum.ACTIVATING_ACCOUNT, 'Activating account...');
|
||||
SessionCommands.activateAccount();
|
||||
break;
|
||||
case WebSocketConnectReason.RECOVER_PASSWORD:
|
||||
console.log('ServerIdentificationData.recoverPassword');
|
||||
case WebSocketConnectReason.PASSWORD_RESET_REQUEST:
|
||||
SessionCommands.resetPasswordRequest();
|
||||
break;
|
||||
case WebSocketConnectReason.PASSWORD_RESET_CHALLENGE:
|
||||
SessionCommands.resetPasswordChallenge();
|
||||
break;
|
||||
case WebSocketConnectReason.PASSWORD_RESET:
|
||||
SessionCommands.resetPassword();
|
||||
break;
|
||||
default:
|
||||
console.error("Undefined type", webClient.options.reason);
|
||||
SessionCommands.updateStatus(StatusEnum.DISCONNECTED, "Unknown Connection Reason: " + webClient.options.reason);
|
||||
SessionCommands.disconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue