mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
More web stuff (#5055)
* Add Response.gamesOfuser * Cleanup and confirm all
This commit is contained in:
parent
f04702fdd1
commit
291c535edb
12 changed files with 71 additions and 24 deletions
34
webclient/src/websocket/commands/session/activate.ts
Normal file
34
webclient/src/websocket/commands/session/activate.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { AccountActivationParams } from 'store';
|
||||
import { StatusEnum, WebSocketConnectOptions } from 'types';
|
||||
|
||||
import webClient from '../../WebClient';
|
||||
import { SessionPersistence } from '../../persistence';
|
||||
|
||||
import { disconnect, login, updateStatus } from './';
|
||||
|
||||
export function activate(options: WebSocketConnectOptions, passwordSalt?: string): void {
|
||||
const { userName, token } = options as unknown as AccountActivationParams;
|
||||
|
||||
const accountActivationConfig = {
|
||||
...webClient.clientConfig,
|
||||
userName,
|
||||
token,
|
||||
};
|
||||
|
||||
const CmdActivate = webClient.protobuf.controller.Command_Activate.create(accountActivationConfig);
|
||||
|
||||
const sc = webClient.protobuf.controller.SessionCommand.create({
|
||||
'.Command_Activate.ext': CmdActivate
|
||||
});
|
||||
|
||||
webClient.protobuf.sendSessionCommand(sc, raw => {
|
||||
if (raw.responseCode === webClient.protobuf.controller.Response.ResponseCode.RespActivationAccepted) {
|
||||
SessionPersistence.accountActivationSuccess();
|
||||
login(options, passwordSalt);
|
||||
} else {
|
||||
updateStatus(StatusEnum.DISCONNECTED, 'Account Activation Failed');
|
||||
disconnect();
|
||||
SessionPersistence.accountActivationFailed();
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue