mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Send emails when 2FA settings are updated
Summary: When user 2FA status is changed, we now send out emails via SendGrid. Test Plan: Server tests. Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki Differential Revision: https://phab.getgrist.com/D3280
This commit is contained in:
parent
8f1889d2d7
commit
ff4e5d2769
@ -35,6 +35,7 @@ import {makeId} from 'app/server/lib/idUtils';
|
|||||||
import * as log from 'app/server/lib/log';
|
import * as log from 'app/server/lib/log';
|
||||||
import {Permit} from 'app/server/lib/Permit';
|
import {Permit} from 'app/server/lib/Permit';
|
||||||
import {WebHookSecret} from "app/server/lib/Triggers";
|
import {WebHookSecret} from "app/server/lib/Triggers";
|
||||||
|
import {StringUnion} from 'app/common/StringUnion';
|
||||||
import {EventEmitter} from 'events';
|
import {EventEmitter} from 'events';
|
||||||
import flatten = require('lodash/flatten');
|
import flatten = require('lodash/flatten');
|
||||||
import pick = require('lodash/pick');
|
import pick = require('lodash/pick');
|
||||||
@ -48,6 +49,17 @@ import * as uuidv4 from "uuid/v4";
|
|||||||
// fixed. See https://github.com/typeorm/typeorm/issues/1884#issuecomment-380767213
|
// fixed. See https://github.com/typeorm/typeorm/issues/1884#issuecomment-380767213
|
||||||
applyPatch();
|
applyPatch();
|
||||||
|
|
||||||
|
export const NotifierEvents = StringUnion(
|
||||||
|
'addUser',
|
||||||
|
'userChange',
|
||||||
|
'firstLogin',
|
||||||
|
'addBillingManager',
|
||||||
|
'teamCreator',
|
||||||
|
'trialPeriodEndingSoon',
|
||||||
|
);
|
||||||
|
|
||||||
|
export type NotifierEvent = typeof NotifierEvents.type;
|
||||||
|
|
||||||
// Nominal email address of a user who can view anything (for thumbnails).
|
// Nominal email address of a user who can view anything (for thumbnails).
|
||||||
export const PREVIEWER_EMAIL = 'thumbnail@getgrist.com';
|
export const PREVIEWER_EMAIL = 'thumbnail@getgrist.com';
|
||||||
|
|
||||||
@ -190,6 +202,10 @@ export class HomeDBManager extends EventEmitter {
|
|||||||
|
|
||||||
private _docAuthCache = new MapWithTTL<string, Promise<DocAuthResult>>(DOC_AUTH_CACHE_TTL);
|
private _docAuthCache = new MapWithTTL<string, Promise<DocAuthResult>>(DOC_AUTH_CACHE_TTL);
|
||||||
|
|
||||||
|
public emit(event: NotifierEvent, ...args: any[]): boolean {
|
||||||
|
return super.emit(event, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Five aclRules, each with one group (with the names 'owners', 'editors', 'viewers',
|
* Five aclRules, each with one group (with the names 'owners', 'editors', 'viewers',
|
||||||
* 'guests', and 'members') are created by default on every new entity (Organization,
|
* 'guests', and 'members') are created by default on every new entity (Organization,
|
||||||
|
@ -99,7 +99,6 @@ export class FlexServer implements GristServer {
|
|||||||
public host: string;
|
public host: string;
|
||||||
public tag: string;
|
public tag: string;
|
||||||
public info = new Array<[string, any]>();
|
public info = new Array<[string, any]>();
|
||||||
public notifier: INotifier;
|
|
||||||
public usage: Usage;
|
public usage: Usage;
|
||||||
public housekeeper: Housekeeper;
|
public housekeeper: Housekeeper;
|
||||||
public server: http.Server;
|
public server: http.Server;
|
||||||
@ -123,6 +122,7 @@ export class FlexServer implements GristServer {
|
|||||||
private _storageManager: IDocStorageManager;
|
private _storageManager: IDocStorageManager;
|
||||||
private _docWorkerMap: IDocWorkerMap;
|
private _docWorkerMap: IDocWorkerMap;
|
||||||
private _widgetRepository: IWidgetRepository;
|
private _widgetRepository: IWidgetRepository;
|
||||||
|
private _notifier: INotifier;
|
||||||
private _internalPermitStore: IPermitStore; // store for permits that stay within our servers
|
private _internalPermitStore: IPermitStore; // store for permits that stay within our servers
|
||||||
private _externalPermitStore: IPermitStore; // store for permits that pass through outside servers
|
private _externalPermitStore: IPermitStore; // store for permits that pass through outside servers
|
||||||
private _disabled: boolean = false;
|
private _disabled: boolean = false;
|
||||||
@ -286,6 +286,11 @@ export class FlexServer implements GristServer {
|
|||||||
return this._widgetRepository;
|
return this._widgetRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getNotifier(): INotifier {
|
||||||
|
if (!this._notifier) { throw new Error('no notifier available'); }
|
||||||
|
return this._notifier;
|
||||||
|
}
|
||||||
|
|
||||||
public addLogging() {
|
public addLogging() {
|
||||||
if (this._check('logging')) { return; }
|
if (this._check('logging')) { return; }
|
||||||
if (process.env.GRIST_LOG_SKIP_HTTP) { return; }
|
if (process.env.GRIST_LOG_SKIP_HTTP) { return; }
|
||||||
@ -1254,7 +1259,7 @@ export class FlexServer implements GristServer {
|
|||||||
// and all that is needed is a refactor to pass that info along. But there is also the
|
// and all that is needed is a refactor to pass that info along. But there is also the
|
||||||
// case of notification(s) from stripe. May need to associate a preferred base domain
|
// case of notification(s) from stripe. May need to associate a preferred base domain
|
||||||
// with org/user and persist that?
|
// with org/user and persist that?
|
||||||
this.notifier = this.create.Notifier(this._dbManager, this);
|
this._notifier = this.create.Notifier(this._dbManager, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getGristConfig(): GristLoadConfig {
|
public getGristConfig(): GristLoadConfig {
|
||||||
|
@ -9,6 +9,7 @@ import * as Comm from 'app/server/lib/Comm';
|
|||||||
import { Hosts } from 'app/server/lib/extractOrg';
|
import { Hosts } from 'app/server/lib/extractOrg';
|
||||||
import { ICreate } from 'app/server/lib/ICreate';
|
import { ICreate } from 'app/server/lib/ICreate';
|
||||||
import { IDocStorageManager } from 'app/server/lib/IDocStorageManager';
|
import { IDocStorageManager } from 'app/server/lib/IDocStorageManager';
|
||||||
|
import { INotifier } from 'app/server/lib/INotifier';
|
||||||
import { IPermitStore } from 'app/server/lib/Permit';
|
import { IPermitStore } from 'app/server/lib/Permit';
|
||||||
import { Sessions } from 'app/server/lib/Sessions';
|
import { Sessions } from 'app/server/lib/Sessions';
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
@ -34,6 +35,7 @@ export interface GristServer {
|
|||||||
getHosts(): Hosts;
|
getHosts(): Hosts;
|
||||||
getHomeDBManager(): HomeDBManager;
|
getHomeDBManager(): HomeDBManager;
|
||||||
getStorageManager(): IDocStorageManager;
|
getStorageManager(): IDocStorageManager;
|
||||||
|
getNotifier(): INotifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GristLoginSystem {
|
export interface GristLoginSystem {
|
||||||
|
Loading…
Reference in New Issue
Block a user