Moved authentication out of protocol handler.

This commit is contained in:
flash 2024-02-29 23:19:36 +00:00
parent 4bc23eabc4
commit caee3ace32
2 changed files with 6 additions and 8 deletions

View file

@ -597,6 +597,9 @@ window.Umi = { UI: {}, Protocol: { SockChat: { Protocol: {} } } };
if(dumpEvents) console.log('conn:ready', ready);
getLoadingOverlay('spinner', 'Loading...', 'Authenticating...');
const authInfo = MamiMisuzuAuth.getInfo();
Umi.Server.sendAuth(authInfo.method, authInfo.token);
});
Umi.Server.watch('conn:lost', lost => {
if(dumpEvents) console.log('conn:lost', lost);

View file

@ -1,5 +1,4 @@
#include common.js
#include mszauth.js
#include servers.js
#include watcher.js
#include websock.js
@ -88,7 +87,7 @@ Umi.Protocol.SockChat.Protocol = function() {
lastPong = undefined;
lastPing = Date.now();
};
const sendAuth = args => {
const sendAuth = (...args) => {
if(selfUserId === undefined)
send('1', ...args);
};
@ -111,16 +110,11 @@ Umi.Protocol.SockChat.Protocol = function() {
isRestarting = false;
watchers.call('conn:ready', {
wasConnected: wasConnected,
});
// see if these are neccesary
watchers.call('user:clear');
watchers.call('chan:clear');
const authInfo = MamiMisuzuAuth.getInfo();
sendAuth([authInfo.method, authInfo.token]);
watchers.call('conn:ready', { wasConnected: wasConnected });
};
const onClose = ev => {
@ -600,6 +594,7 @@ Umi.Protocol.SockChat.Protocol = function() {
};
return {
sendAuth: sendAuth,
sendMessage: sendMessage,
open: () => {
noReconnect = false;