diff options
author | Chocobozzz <me@florianbigard.com> | 2019-06-11 11:54:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-06-11 14:31:11 +0200 |
commit | d1ab89deb79f70c439b58750d044d9cadf1194e5 (patch) | |
tree | 3cd18a0a8a3bf7497aec9d803c759bf54656115c /server/lib/user.ts | |
parent | fff77ba23191f9bca959d5989a1f1df331dbac0b (diff) | |
download | PeerTube-d1ab89deb79f70c439b58750d044d9cadf1194e5.tar.gz PeerTube-d1ab89deb79f70c439b58750d044d9cadf1194e5.tar.zst PeerTube-d1ab89deb79f70c439b58750d044d9cadf1194e5.zip |
Handle email update on server
Diffstat (limited to 'server/lib/user.ts')
-rw-r--r-- | server/lib/user.ts | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/server/lib/user.ts b/server/lib/user.ts index b50b09d72..0e4007770 100644 --- a/server/lib/user.ts +++ b/server/lib/user.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as uuidv4 from 'uuid/v4' | 1 | import * as uuidv4 from 'uuid/v4' |
2 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 2 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
3 | import { SERVER_ACTOR_NAME } from '../initializers/constants' | 3 | import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' |
4 | import { AccountModel } from '../models/account/account' | 4 | import { AccountModel } from '../models/account/account' |
5 | import { UserModel } from '../models/account/user' | 5 | import { UserModel } from '../models/account/user' |
6 | import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub' | 6 | import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub' |
@@ -12,6 +12,8 @@ import { UserNotificationSetting, UserNotificationSettingValue } from '../../sha | |||
12 | import { createWatchLaterPlaylist } from './video-playlist' | 12 | import { createWatchLaterPlaylist } from './video-playlist' |
13 | import { sequelizeTypescript } from '../initializers/database' | 13 | import { sequelizeTypescript } from '../initializers/database' |
14 | import { Transaction } from 'sequelize/types' | 14 | import { Transaction } from 'sequelize/types' |
15 | import { Redis } from './redis' | ||
16 | import { Emailer } from './emailer' | ||
15 | 17 | ||
16 | type ChannelNames = { name: string, displayName: string } | 18 | type ChannelNames = { name: string, displayName: string } |
17 | async function createUserAccountAndChannelAndPlaylist (parameters: { | 19 | async function createUserAccountAndChannelAndPlaylist (parameters: { |
@@ -100,12 +102,24 @@ async function createApplicationActor (applicationId: number) { | |||
100 | return accountCreated | 102 | return accountCreated |
101 | } | 103 | } |
102 | 104 | ||
105 | async function sendVerifyUserEmail (user: UserModel, isPendingEmail = false) { | ||
106 | const verificationString = await Redis.Instance.setVerifyEmailVerificationString(user.id) | ||
107 | let url = WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString | ||
108 | |||
109 | if (isPendingEmail) url += '&isPendingEmail=true' | ||
110 | |||
111 | const email = isPendingEmail ? user.pendingEmail : user.email | ||
112 | |||
113 | await Emailer.Instance.addVerifyEmailJob(email, url) | ||
114 | } | ||
115 | |||
103 | // --------------------------------------------------------------------------- | 116 | // --------------------------------------------------------------------------- |
104 | 117 | ||
105 | export { | 118 | export { |
106 | createApplicationActor, | 119 | createApplicationActor, |
107 | createUserAccountAndChannelAndPlaylist, | 120 | createUserAccountAndChannelAndPlaylist, |
108 | createLocalAccountWithoutKeys | 121 | createLocalAccountWithoutKeys, |
122 | sendVerifyUserEmail | ||
109 | } | 123 | } |
110 | 124 | ||
111 | // --------------------------------------------------------------------------- | 125 | // --------------------------------------------------------------------------- |