(core) Allowing non-owner managers to add other managers

Summary:
Billing managers can now add other billing managers. Before
only managers with owner access could do that.

Test Plan: Added test

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D4339
This commit is contained in:
Jarosław Sadziński
2024-09-09 17:58:42 +02:00
parent 963e26dda6
commit 51acc9a8cc
3 changed files with 28 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
import {normalizeEmail} from 'app/common/emails';
import {UserPrefs} from 'app/common/Prefs';
// User profile info for the user. When using Cognito, it is fetched during login.
@@ -12,6 +13,21 @@ export interface UserProfile {
locale?: string|null;
}
/**
* Tries to compare two user profiles to see if they represent the same user.
* Note: if you have access to FullUser objects, comparing ids is more reliable.
*/
export function sameUser(a: UserProfile|FullUser, b: UserProfile|FullUser): boolean {
if ('id' in a && 'id' in b) {
return a.id === b.id;
}
if (a.loginEmail && b.loginEmail) {
return a.loginEmail === b.loginEmail;
} else {
return normalizeEmail(a.email) === normalizeEmail(b.email);
}
}
// User profile including user id and user ref. All information in it should
// have been validated against database.
export interface FullUser extends UserProfile {