mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Remove LoginSession, which was mainly serving situations that are no longer used.
Summary: In the past, Cognito sign-ins were intended to give authorization to some AWS services (like SQS); various tokens were stored in the session for this purpose. This is no longer used. Profiles from Cognito now serve a limited purpose: first-time initialization of name and picture, and keeping track of which login method was used. For these remaining needs, ScopedSession is sufficient. Test Plan: Existing test pass. Tested manually that logins work with Google and Email + Password. Tested manually that on a clean database, name and picture are picked up from a Google Login. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2907
This commit is contained in:
@@ -8,9 +8,9 @@ import {User} from 'app/gen-server/entity/User';
|
||||
import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager';
|
||||
import {ActiveDoc} from 'app/server/lib/ActiveDoc';
|
||||
import {Authorizer} from 'app/server/lib/Authorizer';
|
||||
import {ScopedSession} from 'app/server/lib/BrowserSession';
|
||||
import {DocSession} from 'app/server/lib/DocSession';
|
||||
import * as log from 'app/server/lib/log';
|
||||
import {ILoginSession} from 'app/server/lib/ILoginSession';
|
||||
import {shortDesc} from 'app/server/lib/shortDesc';
|
||||
import * as crypto from 'crypto';
|
||||
import * as moment from 'moment';
|
||||
@@ -61,10 +61,10 @@ void(MESSAGE_TYPES_NO_AUTH);
|
||||
export class Client {
|
||||
public readonly clientId: string;
|
||||
|
||||
public session: ILoginSession|null = null;
|
||||
|
||||
public browserSettings: BrowserSettings = {};
|
||||
|
||||
private _session: ScopedSession|null = null;
|
||||
|
||||
// Maps docFDs to DocSession objects.
|
||||
private _docFDs: Array<DocSession|null> = [];
|
||||
|
||||
@@ -221,21 +221,16 @@ export class Client {
|
||||
}
|
||||
}
|
||||
|
||||
// Assigns the client to the given login session and the session to the client.
|
||||
public setSession(session: ILoginSession): void {
|
||||
this.unsetSession();
|
||||
this.session = session;
|
||||
session.clients.add(this);
|
||||
// Assigns the given ScopedSession to the client.
|
||||
public setSession(session: ScopedSession): void {
|
||||
this._session = session;
|
||||
}
|
||||
|
||||
// Unsets the current login session and removes the client from it.
|
||||
public unsetSession(): void {
|
||||
if (this.session) { this.session.clients.delete(this); }
|
||||
this.session = null;
|
||||
public getSession(): ScopedSession|null {
|
||||
return this._session;
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.unsetSession();
|
||||
this._destroyed = true;
|
||||
}
|
||||
|
||||
@@ -318,6 +313,14 @@ export class Client {
|
||||
return this._profile;
|
||||
}
|
||||
|
||||
public async getSessionProfile(): Promise<UserProfile|null|undefined> {
|
||||
return this._session?.getSessionProfile();
|
||||
}
|
||||
|
||||
public async getSessionEmail(): Promise<string|null> {
|
||||
return (await this.getSessionProfile())?.email || null;
|
||||
}
|
||||
|
||||
public getCachedUserId(): number|null {
|
||||
return this._userId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user