mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
Webatrice: support hashed passwords in register and resetPassword (#4549)
* support hashed passwords in register and resetPassword * lint * support hashedPasswords for accountActivation * use salt in post-register login step Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
parent
92f941a54c
commit
992e28797f
3 changed files with 64 additions and 15 deletions
|
|
@ -3,6 +3,7 @@ import { Room, StatusEnum, User, WebSocketConnectReason } from 'types';
|
|||
import { SessionCommands } from '../commands';
|
||||
import { RoomPersistence, SessionPersistence } from '../persistence';
|
||||
import { ProtobufEvents } from '../services/ProtobufService';
|
||||
import { passwordSaltSupported } from '../utils';
|
||||
import webClient from '../WebClient';
|
||||
|
||||
export const SessionEvents: ProtobufEvents = {
|
||||
|
|
@ -122,18 +123,25 @@ function serverIdentification(info: ServerIdentificationData) {
|
|||
switch (webClient.options.reason) {
|
||||
case WebSocketConnectReason.LOGIN:
|
||||
SessionCommands.updateStatus(StatusEnum.LOGGING_IN, 'Logging In...');
|
||||
// Intentional use of Bitwise operator b/c of how Servatrice Enums work
|
||||
if (serverOptions & webClient.protobuf.controller.Event_ServerIdentification.ServerOptions.SupportsPasswordHash) {
|
||||
if (passwordSaltSupported(serverOptions, webClient)) {
|
||||
SessionCommands.requestPasswordSalt();
|
||||
} else {
|
||||
SessionCommands.login();
|
||||
}
|
||||
break;
|
||||
case WebSocketConnectReason.REGISTER:
|
||||
SessionCommands.register();
|
||||
if (passwordSaltSupported(serverOptions, webClient)) {
|
||||
SessionCommands.requestPasswordSalt();
|
||||
} else {
|
||||
SessionCommands.register();
|
||||
}
|
||||
break;
|
||||
case WebSocketConnectReason.ACTIVATE_ACCOUNT:
|
||||
SessionCommands.activateAccount();
|
||||
if (passwordSaltSupported(serverOptions, webClient)) {
|
||||
SessionCommands.requestPasswordSalt();
|
||||
} else {
|
||||
SessionCommands.activateAccount();
|
||||
}
|
||||
break;
|
||||
case WebSocketConnectReason.PASSWORD_RESET_REQUEST:
|
||||
SessionCommands.resetPasswordRequest();
|
||||
|
|
@ -142,7 +150,11 @@ function serverIdentification(info: ServerIdentificationData) {
|
|||
SessionCommands.resetPasswordChallenge();
|
||||
break;
|
||||
case WebSocketConnectReason.PASSWORD_RESET:
|
||||
SessionCommands.resetPassword();
|
||||
if (passwordSaltSupported(serverOptions, webClient)) {
|
||||
SessionCommands.requestPasswordSalt();
|
||||
} else {
|
||||
SessionCommands.resetPassword();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SessionCommands.updateStatus(StatusEnum.DISCONNECTED, 'Unknown Connection Reason: ' + webClient.options.reason);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue