fix authentication fail after login
This commit is contained in:
parent
6111d1dfa3
commit
c5210b40c3
3 changed files with 6 additions and 10 deletions
|
@ -1,15 +1,13 @@
|
|||
import Logger from '../Util/Logger';
|
||||
import gateway from "./Gateway/globalGatewayConnection";
|
||||
import token from "./TokenManager";
|
||||
|
||||
const { log: authLog } = Logger([ 'Authenticator' ]);
|
||||
|
||||
const Authenticator = {
|
||||
getToken: function() {
|
||||
return localStorage.getItem("token");
|
||||
},
|
||||
login: async function() {
|
||||
authLog('Logging in through gateway...');
|
||||
return gateway.connect();
|
||||
return gateway.connect(token.getToken());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -45,13 +45,12 @@ const getOpcodeByName = (name) => {
|
|||
|
||||
|
||||
class GatewayConnection {
|
||||
constructor(token, gatewayUrl) {
|
||||
this.token = token;
|
||||
constructor(gatewayUrl) {
|
||||
this.gatewayUrl = gatewayUrl;
|
||||
}
|
||||
}
|
||||
|
||||
GatewayConnection.prototype.connect = function() {
|
||||
GatewayConnection.prototype.connect = function(token) {
|
||||
this.ws = new WebSocket(this.gatewayUrl);
|
||||
|
||||
this.handshakeCompleted = false;
|
||||
|
@ -73,7 +72,7 @@ GatewayConnection.prototype.connect = function() {
|
|||
// Got HELLO from server, send YOO as soon as possible
|
||||
logGateway("Got HELLO", packet.data);
|
||||
logGateway("Sending YOO");
|
||||
this.ws.send(this.packet("YOO", { token: this.token }));
|
||||
this.ws.send(this.packet("YOO", { token }));
|
||||
break;
|
||||
}
|
||||
case "YOO_ACK": {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import GatewayConnection from './GatewayConnection';
|
||||
import config from '../../Config';
|
||||
import token from '../TokenManager';
|
||||
import store from '../../Global/store';
|
||||
|
||||
const globalGatewayConnection = new GatewayConnection(token.getToken(), config.gatewayUrl);
|
||||
const globalGatewayConnection = new GatewayConnection(config.gatewayUrl);
|
||||
|
||||
globalGatewayConnection.onopen = (sessionData) => {
|
||||
store.dispatch({ type: 'gateway/connectionstatus', gateway: { isConnected: true } });
|
||||
|
|
Loading…
Reference in a new issue