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

@ -6,7 +6,7 @@ import { SessionPersistence } from '../../persistence';
import { disconnect, login, updateStatus } from './';
export function activateAccount(options: WebSocketConnectOptions, passwordSalt?: string): void {
export function activate(options: WebSocketConnectOptions, passwordSalt?: string): void {
const { userName, token } = options as unknown as AccountActivationParams;
const accountActivationConfig = {

View file

@ -5,7 +5,7 @@ import webClient from '../../WebClient';
import { SessionPersistence } from '../../persistence';
import { disconnect, updateStatus } from './';
export function resetPasswordChallenge(options: WebSocketConnectOptions): void {
export function forgotPasswordChallenge(options: WebSocketConnectOptions): void {
const { userName, email } = options as unknown as ForgotPasswordChallengeParams;
const forgotPasswordChallengeConfig = {

View file

@ -7,7 +7,7 @@ import { hashPassword } from '../../utils';
import { disconnect, updateStatus } from '.';
export function resetPassword(options: WebSocketConnectOptions, passwordSalt?: string): void {
export function forgotPasswordRequest(options: WebSocketConnectOptions, passwordSalt?: string): void {
const { userName, token, newPassword } = options as unknown as ForgotPasswordResetParams;
const forgotPasswordResetConfig: any = {

View file

@ -0,0 +1,29 @@
import webClient from '../../WebClient';
import { SessionPersistence } from '../../persistence';
export function getGamesOfUser(userName: string): void {
const command = webClient.protobuf.controller.Command_GetGamesOfUser.create({ userName });
const sc = webClient.protobuf.controller.SessionCommand.create({
'.Command_GetGamesOfUser.ext': command
});
webClient.protobuf.sendSessionCommand(sc, raw => {
const { responseCode } = raw;
const response = raw['.Response_GetGamesOfUser.ext'];
switch (responseCode) {
case webClient.protobuf.controller.Response.ResponseCode.RespOk:
SessionPersistence.getGamesOfUser(userName, response);
break;
case webClient.protobuf.controller.Response.ResponseCode.RespFunctionNotAllowed:
console.log('Not allowed');
break;
case webClient.protobuf.controller.Response.ResponseCode.RespWrongPassword:
console.log('Wrong password');
break;
default:
console.log('Failed to update information');
}
});
}

View file

@ -1,4 +1,4 @@
export * from './activateAccount';
export * from './activate';
export * from './addToList';
export * from './connect';
export * from './disconnect';
@ -9,8 +9,8 @@ export * from './login';
export * from './register';
export * from './removeFromList';
export * from './requestPasswordSalt';
export * from './resetPassword';
export * from './resetPasswordChallenge'
export * from './forgotPasswordRequest';
export * from './forgotPasswordChallenge'
export * from './resetPasswordRequest';
export * from './updateStatus';
export * from './accountPassword';
@ -18,3 +18,5 @@ export * from './accountEdit';
export * from './accountImage';
export * from './message';
export * from './getUserInfo';
export * from './getGamesOfUser';
export * from './ping';

View file

@ -0,0 +1,12 @@
import webClient from '../../WebClient';
import { SessionPersistence } from '../../persistence';
export function ping(pingReceived: Function): void {
const command = webClient.protobuf.controller.Command_Ping.create();
const sc = webClient.protobuf.controller.SessionCommand.create({
'.Command_Ping.ext': command
});
webClient.protobuf.sendSessionCommand(sc, pingReceived);
}

View file

@ -5,10 +5,10 @@ import webClient from '../../WebClient';
import { SessionPersistence } from '../../persistence';
import {
activateAccount,
activate,
disconnect,
login,
resetPassword,
forgotPasswordRequest,
updateStatus
} from './';
@ -33,12 +33,12 @@ export function requestPasswordSalt(options: WebSocketConnectOptions): void {
switch (options.reason) {
case WebSocketConnectReason.ACTIVATE_ACCOUNT: {
activateAccount(options, passwordSalt);
activate(options, passwordSalt);
break;
}
case WebSocketConnectReason.PASSWORD_RESET: {
resetPassword(options, passwordSalt);
forgotPasswordRequest(options, passwordSalt);
break;
}