2023-04-11 05:00:28 +00:00
|
|
|
import {UserPrefs} from 'app/common/Prefs';
|
|
|
|
|
2020-07-21 13:20:51 +00:00
|
|
|
// User profile info for the user. When using Cognito, it is fetched during login.
|
|
|
|
export interface UserProfile {
|
2024-02-14 16:01:02 +00:00
|
|
|
email: string; // TODO: Used inconsistently: as lowercase login email or display email.
|
|
|
|
loginEmail?: string; // When set, this is consistently normalized (lowercase) login email.
|
2020-07-21 13:20:51 +00:00
|
|
|
name: string;
|
|
|
|
picture?: string|null; // when present, a url to a public image of unspecified dimensions.
|
|
|
|
anonymous?: boolean; // when present, asserts whether user is anonymous (not authorized).
|
2022-05-18 10:25:14 +00:00
|
|
|
connectId?: string|null, // used by GristConnect to identify user in external provider.
|
|
|
|
loginMethod?: 'Google'|'Email + Password'|'External';
|
2023-01-24 13:13:18 +00:00
|
|
|
locale?: string|null;
|
2020-07-21 13:20:51 +00:00
|
|
|
}
|
|
|
|
|
2022-10-03 14:45:44 +00:00
|
|
|
// User profile including user id and user ref. All information in it should
|
2020-07-21 13:20:51 +00:00
|
|
|
// have been validated against database.
|
|
|
|
export interface FullUser extends UserProfile {
|
|
|
|
id: number;
|
2022-10-03 14:45:44 +00:00
|
|
|
ref?: string|null; // Not filled for anonymous users.
|
2022-02-14 21:26:21 +00:00
|
|
|
allowGoogleLogin?: boolean; // when present, specifies whether logging in via Google is possible.
|
2022-10-14 15:39:15 +00:00
|
|
|
isSupport?: boolean; // set if user is a special support user.
|
2023-04-11 05:00:28 +00:00
|
|
|
prefs?: UserPrefs;
|
2020-07-21 13:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface LoginSessionAPI {
|
|
|
|
/**
|
|
|
|
* Logs out by clearing all data in the session store besides the session cookie itself.
|
|
|
|
* Broadcasts the logged out state to all clients.
|
|
|
|
*/
|
|
|
|
logout(): Promise<void>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Replaces the user profile object in the session and broadcasts the new profile to all clients.
|
|
|
|
*/
|
|
|
|
updateProfile(profile: UserProfile): Promise<void>;
|
|
|
|
}
|