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,19 +8,19 @@ export interface SessionUserObj {
|
||||
// a grist-internal identify for the user, if known.
|
||||
userId?: number;
|
||||
|
||||
// The user profile object. When updated, all clients get a message with the update.
|
||||
// The user profile object.
|
||||
profile?: UserProfile;
|
||||
|
||||
// Authentication provider string indicating the login method used.
|
||||
// [UNUSED] Authentication provider string indicating the login method used.
|
||||
authProvider?: string;
|
||||
|
||||
// Login ID token used to access AWS services.
|
||||
// [UNUSED] Login ID token used to access AWS services.
|
||||
idToken?: string;
|
||||
|
||||
// Login access token used to access other AWS services.
|
||||
// [UNUSED] Login access token used to access other AWS services.
|
||||
accessToken?: string;
|
||||
|
||||
// Login refresh token used to retrieve new ID and access tokens.
|
||||
// [UNUSED] Login refresh token used to retrieve new ID and access tokens.
|
||||
refreshToken?: string;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,26 @@ export class ScopedSession {
|
||||
return getSessionUser(session, this._org, this._userSelector) || {};
|
||||
}
|
||||
|
||||
// Retrieves the user profile from the session.
|
||||
public async getSessionProfile(prev?: SessionObj): Promise<UserProfile|null> {
|
||||
return (await this.getScopedSession(prev)).profile || null;
|
||||
}
|
||||
|
||||
// Updates a user profile. The session may have multiple profiles associated with different
|
||||
// email addresses. This will update the one with a matching email address, or add a new one.
|
||||
// This is mainly used to know which emails are logged in in this session; fields like name and
|
||||
// picture URL come from the database instead.
|
||||
public async updateUserProfile(profile: UserProfile|null): Promise<void> {
|
||||
if (profile) {
|
||||
await this.operateOnScopedSession(async user => {
|
||||
user.profile = profile;
|
||||
return user;
|
||||
});
|
||||
} else {
|
||||
await this.clearScopedSession();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This performs an operation on the session object, limited to a single user entry. The state of that
|
||||
|
||||
Reference in New Issue
Block a user