mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
e264094412
Summary: Enabled by default, the new checkbox is only visible to users logged in with email/password, and controls whether it is possible to log in to the same account via a Google account (with matching email). When disabled, CognitoClient will refuse logins from Google if a Grist account with the same email exists. Test Plan: Server and browser tests for setting flag. Manual tests to verify Cognito doesn't allow signing in with Google when flag is disabled. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3257
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import {UserOptions} from 'app/common/UserAPI';
|
|
import {nativeValues} from 'app/gen-server/lib/values';
|
|
import {BaseEntity, Column, Entity, JoinTable, ManyToMany, OneToMany, OneToOne,
|
|
PrimaryGeneratedColumn} from "typeorm";
|
|
|
|
import {Group} from "./Group";
|
|
import {Login} from "./Login";
|
|
import {Organization} from "./Organization";
|
|
|
|
@Entity({name: 'users'})
|
|
export class User extends BaseEntity {
|
|
|
|
@PrimaryGeneratedColumn()
|
|
public id: number;
|
|
|
|
@Column()
|
|
public name: string;
|
|
|
|
@Column({name: 'api_key', type: String, nullable: true})
|
|
// Found how to make a type nullable in this discussion: https://github.com/typeorm/typeorm/issues/2567
|
|
// todo: adds constraint for api_key not to equal ''
|
|
public apiKey: string | null;
|
|
|
|
@Column({name: 'picture', type: String, nullable: true})
|
|
public picture: string | null;
|
|
|
|
@Column({name: 'first_login_at', type: Date, nullable: true})
|
|
public firstLoginAt: Date | null;
|
|
|
|
@OneToOne(type => Organization, organization => organization.owner)
|
|
public personalOrg: Organization;
|
|
|
|
@OneToMany(type => Login, login => login.user)
|
|
public logins: Login[];
|
|
|
|
@ManyToMany(type => Group)
|
|
@JoinTable({
|
|
name: 'group_users',
|
|
joinColumn: {name: 'user_id'},
|
|
inverseJoinColumn: {name: 'group_id'}
|
|
})
|
|
public groups: Group[];
|
|
|
|
@Column({name: 'is_first_time_user', default: false})
|
|
public isFirstTimeUser: boolean;
|
|
|
|
@Column({name: 'options', type: nativeValues.jsonEntityType, nullable: true})
|
|
public options: UserOptions | null;
|
|
|
|
/**
|
|
* Get user's email. Returns undefined if logins has not been joined, or no login
|
|
* is available
|
|
*/
|
|
public get loginEmail(): string|undefined {
|
|
const login = this.logins && this.logins[0];
|
|
if (!login) { return undefined; }
|
|
return login.email;
|
|
}
|
|
}
|