More web stuff (#5055)

* Add Response.gamesOfuser

* Cleanup and confirm all
This commit is contained in:
Zach H 2024-06-16 22:48:07 -04:00 committed by GitHub
parent f04702fdd1
commit 291c535edb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 71 additions and 24 deletions

View file

@ -0,0 +1,42 @@
import { ForgotPasswordResetParams } from 'store';
import { StatusEnum, WebSocketConnectOptions } from 'types';
import webClient from '../../WebClient';
import { SessionPersistence } from '../../persistence';
import { hashPassword } from '../../utils';
import { disconnect, updateStatus } from '.';
export function forgotPasswordRequest(options: WebSocketConnectOptions, passwordSalt?: string): void {
const { userName, token, newPassword } = options as unknown as ForgotPasswordResetParams;
const forgotPasswordResetConfig: any = {
...webClient.clientConfig,
userName,
token,
};
if (passwordSalt) {
forgotPasswordResetConfig.hashedNewPassword = hashPassword(passwordSalt, newPassword);
} else {
forgotPasswordResetConfig.newPassword = newPassword;
}
const CmdForgotPasswordReset = webClient.protobuf.controller.Command_ForgotPasswordReset.create(forgotPasswordResetConfig);
const sc = webClient.protobuf.controller.SessionCommand.create({
'.Command_ForgotPasswordReset.ext': CmdForgotPasswordReset
});
webClient.protobuf.sendSessionCommand(sc, raw => {
if (raw.responseCode === webClient.protobuf.controller.Response.ResponseCode.RespOk) {
updateStatus(StatusEnum.DISCONNECTED, null);
SessionPersistence.resetPasswordSuccess();
} else {
updateStatus(StatusEnum.DISCONNECTED, null);
SessionPersistence.resetPasswordFailed();
}
disconnect();
});
}