mirror of
https://github.com/wassname/talk.git
synced 2026-07-31 12:50:48 +08:00
[next] Email (#2261)
* feat: suspending, banning, now propogation * feat: added email rendering + localization support * fix: fix related to lib * refactor: moved juicer to queue task * refactor: cleanup of job processor * refactor: improved error messaging around failed email * feat: initial forgot passwor impl * fix: fixed rebase errors * feat: send back Content-Language header with requests * feat: added ban email * feat: implemented forgotten password API * fix: linting * feat: support more emails * fix: promise patches * feat: initial confirm email API * feat: added rate limiting * feat: added URL support * feat: added email docs * fix: updated docs * chore: documentation review * fix: fixed build bug * feat: implement forgot password in auth popup * test: add tests + fixes * chore: rename StatelessComponent to FunctionComponent * fix: types and test fixes * chore: upgrade deps * fix: THANK YOU TESTS FOR SAVING MY A** * chore: reorder imports * chore: remove obsolete ! * feat: implement accounts bundle * refactor: review suggestion * fix: rebase upgrade error * fix: rebase bug * feat: reset password link support * test: add tests for account password reset page * fix: remove redirect uri * fix: revert local state changes
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import bunyan from "bunyan";
|
||||
import uuid from "uuid";
|
||||
|
||||
import { LanguageCode } from "talk-common/helpers/i18n/locales";
|
||||
import { Config } from "talk-server/config";
|
||||
import logger from "talk-server/logger";
|
||||
import logger, { Logger } from "talk-server/logger";
|
||||
import { User } from "talk-server/models/user";
|
||||
import { I18n } from "talk-server/services/i18n";
|
||||
import { Request } from "talk-server/types/express";
|
||||
@@ -13,6 +12,7 @@ export interface CommonContextOptions {
|
||||
now?: Date;
|
||||
user?: User;
|
||||
req?: Request;
|
||||
logger?: Logger;
|
||||
lang?: LanguageCode;
|
||||
config: Config;
|
||||
i18n: I18n;
|
||||
@@ -26,11 +26,12 @@ export default class CommonContext {
|
||||
public readonly i18n: I18n;
|
||||
public readonly lang: LanguageCode;
|
||||
public readonly now: Date;
|
||||
public readonly logger: ReturnType<typeof bunyan.createLogger>;
|
||||
public readonly logger: Logger;
|
||||
|
||||
constructor({
|
||||
id = uuid.v1(),
|
||||
now = new Date(),
|
||||
logger: log = logger,
|
||||
user,
|
||||
req,
|
||||
config,
|
||||
@@ -38,9 +39,9 @@ export default class CommonContext {
|
||||
lang = i18n.getDefaultLang(),
|
||||
}: CommonContextOptions) {
|
||||
this.id = id;
|
||||
this.logger = logger.child({
|
||||
this.logger = log.child({
|
||||
context: "graph",
|
||||
contextID: this.id,
|
||||
contextID: id,
|
||||
});
|
||||
this.now = now;
|
||||
this.user = user;
|
||||
|
||||
@@ -52,7 +52,7 @@ export const Users = (ctx: TenantContext) => ({
|
||||
),
|
||||
setEmail: async (input: GQLSetEmailInput): Promise<Readonly<User> | null> =>
|
||||
mapFieldsetToErrorCodes(
|
||||
setEmail(ctx.mongo, ctx.tenant, ctx.user!, input.email),
|
||||
setEmail(ctx.mongo, ctx.mailerQueue, ctx.tenant, ctx.user!, input.email),
|
||||
{
|
||||
"input.email": [
|
||||
ERROR_CODES.EMAIL_ALREADY_SET,
|
||||
@@ -69,7 +69,13 @@ export const Users = (ctx: TenantContext) => ({
|
||||
updatePassword: async (
|
||||
input: GQLUpdatePasswordInput
|
||||
): Promise<Readonly<User> | null> =>
|
||||
updatePassword(ctx.mongo, ctx.tenant, ctx.user!, input.password),
|
||||
updatePassword(
|
||||
ctx.mongo,
|
||||
ctx.mailerQueue,
|
||||
ctx.tenant,
|
||||
ctx.user!,
|
||||
input.password
|
||||
),
|
||||
createToken: async (input: GQLCreateTokenInput) =>
|
||||
createToken(
|
||||
ctx.mongo,
|
||||
@@ -91,10 +97,18 @@ export const Users = (ctx: TenantContext) => ({
|
||||
updateUserRole: async (input: GQLUpdateUserRoleInput) =>
|
||||
updateRole(ctx.mongo, ctx.tenant, ctx.user!, input.userID, input.role),
|
||||
ban: async (input: GQLBanUserInput) =>
|
||||
ban(ctx.mongo, ctx.tenant, ctx.user!, input.userID, ctx.now),
|
||||
ban(
|
||||
ctx.mongo,
|
||||
ctx.mailerQueue,
|
||||
ctx.tenant,
|
||||
ctx.user!,
|
||||
input.userID,
|
||||
ctx.now
|
||||
),
|
||||
suspend: async (input: GQLSuspendUserInput) =>
|
||||
suspend(
|
||||
ctx.mongo,
|
||||
ctx.mailerQueue,
|
||||
ctx.tenant,
|
||||
ctx.user!,
|
||||
input.userID,
|
||||
|
||||
@@ -536,6 +536,9 @@ type OIDCAuthIntegration {
|
||||
##########################
|
||||
|
||||
type GoogleAuthIntegration {
|
||||
"""
|
||||
enabled, when true, will enable Google as an authentication integration.
|
||||
"""
|
||||
enabled: Boolean!
|
||||
|
||||
"""
|
||||
@@ -551,7 +554,14 @@ type GoogleAuthIntegration {
|
||||
"""
|
||||
targetFilter: AuthenticationTargetFilter!
|
||||
|
||||
"""
|
||||
clientID is the Client Identifier as provided by the Google API Console.
|
||||
"""
|
||||
clientID: String @auth(roles: [ADMIN])
|
||||
|
||||
"""
|
||||
clientSecret is the Client Secret as provided by the Google API Console.
|
||||
"""
|
||||
clientSecret: String @auth(roles: [ADMIN])
|
||||
|
||||
"""
|
||||
@@ -574,6 +584,9 @@ type GoogleAuthIntegration {
|
||||
##########################
|
||||
|
||||
type FacebookAuthIntegration {
|
||||
"""
|
||||
enabled, when true, will enable Facebook as an authentication integration.
|
||||
"""
|
||||
enabled: Boolean!
|
||||
|
||||
"""
|
||||
@@ -589,7 +602,16 @@ type FacebookAuthIntegration {
|
||||
"""
|
||||
targetFilter: AuthenticationTargetFilter!
|
||||
|
||||
"""
|
||||
clientID is the Client Identifier as provided by the Facebook Developer
|
||||
Console.
|
||||
"""
|
||||
clientID: String @auth(roles: [ADMIN])
|
||||
|
||||
"""
|
||||
clientSecret is the Client Secret as provided by the Facebook Developer
|
||||
Console.
|
||||
"""
|
||||
clientSecret: String @auth(roles: [ADMIN])
|
||||
|
||||
"""
|
||||
@@ -1343,7 +1365,7 @@ type User {
|
||||
)
|
||||
|
||||
"""
|
||||
comments are the comments of the User.
|
||||
comments are the comments written by the User.
|
||||
"""
|
||||
comments(
|
||||
first: Int = 10
|
||||
@@ -1352,8 +1374,8 @@ type User {
|
||||
): CommentsConnection! @auth(roles: [ADMIN, MODERATOR], userIDField: "id")
|
||||
|
||||
"""
|
||||
commentModerationActionHistory returns a CommentModerationActionConnection that this User has
|
||||
created.
|
||||
commentModerationActionHistory returns a CommentModerationActionConnection
|
||||
that this User has created.
|
||||
"""
|
||||
commentModerationActionHistory(
|
||||
first: Int = 10
|
||||
@@ -1373,7 +1395,7 @@ type User {
|
||||
"""
|
||||
createdAt is the time that the User was created at.
|
||||
"""
|
||||
createdAt: Time! @auth(roles: [ADMIN, MODERATOR], userIDField: "id")
|
||||
createdAt: Time!
|
||||
}
|
||||
|
||||
"""
|
||||
@@ -2377,6 +2399,9 @@ input SettingsSSOAuthIntegrationInput {
|
||||
}
|
||||
|
||||
input SettingsGoogleAuthIntegrationInput {
|
||||
"""
|
||||
enabled, when true, will enable Google as an authentication integration.
|
||||
"""
|
||||
enabled: Boolean
|
||||
|
||||
"""
|
||||
@@ -2392,11 +2417,21 @@ input SettingsGoogleAuthIntegrationInput {
|
||||
"""
|
||||
targetFilter: SettingsAuthenticationTargetFilterInput
|
||||
|
||||
"""
|
||||
clientID is the Client Identifier as provided by the Google API Console.
|
||||
"""
|
||||
clientID: String
|
||||
|
||||
"""
|
||||
clientSecret is the Client Secret as provided by the Google API Console.
|
||||
"""
|
||||
clientSecret: String
|
||||
}
|
||||
|
||||
input SettingsFacebookAuthIntegrationInput {
|
||||
"""
|
||||
enabled, when true, will enable Facebook as an authentication integration.
|
||||
"""
|
||||
enabled: Boolean
|
||||
|
||||
"""
|
||||
@@ -2412,7 +2447,16 @@ input SettingsFacebookAuthIntegrationInput {
|
||||
"""
|
||||
targetFilter: SettingsAuthenticationTargetFilterInput
|
||||
|
||||
"""
|
||||
clientID is the Client Identifier as provided by the Facebook Developer
|
||||
Console.
|
||||
"""
|
||||
clientID: String
|
||||
|
||||
"""
|
||||
clientSecret is the Client Secret as provided by the Facebook Developer
|
||||
Console.
|
||||
"""
|
||||
clientSecret: String
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user