mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Move user profile to new page and begin MFA work
Summary: The user profile dialog is now a separate page, in preparation for upcoming work to enable MFA. This commit also contains some MFA changes, but the UI is currently disabled and the implementation is limited to software tokens (TOTP) only. Test Plan: Updated browser tests for new profile page. Tests for MFAConfig and CognitoClient will be added in a later diff, once the UI is enabled. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D3199
This commit is contained in:
@@ -13,16 +13,22 @@ export interface SessionUserObj {
|
||||
// The user profile object.
|
||||
profile?: UserProfile;
|
||||
|
||||
/**
|
||||
* Unix time in seconds of the last successful login. Includes security
|
||||
* verification prompts, such as those for configuring MFA preferences.
|
||||
*/
|
||||
lastLoginTimestamp?: number;
|
||||
|
||||
// [UNUSED] Authentication provider string indicating the login method used.
|
||||
authProvider?: string;
|
||||
|
||||
// [UNUSED] Login ID token used to access AWS services.
|
||||
idToken?: string;
|
||||
|
||||
// [UNUSED] Login access token used to access other AWS services.
|
||||
// Login access token used to access other AWS services.
|
||||
accessToken?: string;
|
||||
|
||||
// [UNUSED] Login refresh token used to retrieve new ID and access tokens.
|
||||
// Login refresh token used to retrieve new ID and access tokens.
|
||||
refreshToken?: string;
|
||||
|
||||
// State for SAML-mediated logins.
|
||||
@@ -166,14 +172,16 @@ export class ScopedSession {
|
||||
// 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(req: Request, profile: UserProfile|null): Promise<void> {
|
||||
if (profile) {
|
||||
await this.operateOnScopedSession(req, async user => {
|
||||
user.profile = profile;
|
||||
return user;
|
||||
});
|
||||
} else {
|
||||
await this.clearScopedSession(req);
|
||||
}
|
||||
profile ? await this.updateUser(req, {profile}) : await this.clearScopedSession(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the properties of the current session user.
|
||||
*
|
||||
* @param {Partial<SessionUserObj>} newProps New property values to set.
|
||||
*/
|
||||
public async updateUser(req: Request, newProps: Partial<SessionUserObj>): Promise<void> {
|
||||
await this.operateOnScopedSession(req, async user => ({...user, ...newProps}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user