aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-06-11 11:54:33 +0200
committerChocobozzz <me@florianbigard.com>2019-06-11 14:31:11 +0200
commitd1ab89deb79f70c439b58750d044d9cadf1194e5 (patch)
tree3cd18a0a8a3bf7497aec9d803c759bf54656115c /server/lib
parentfff77ba23191f9bca959d5989a1f1df331dbac0b (diff)
downloadPeerTube-d1ab89deb79f70c439b58750d044d9cadf1194e5.tar.gz
PeerTube-d1ab89deb79f70c439b58750d044d9cadf1194e5.tar.zst
PeerTube-d1ab89deb79f70c439b58750d044d9cadf1194e5.zip
Handle email update on server
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/user.ts18
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 @@
1import * as uuidv4 from 'uuid/v4' 1import * as uuidv4 from 'uuid/v4'
2import { ActivityPubActorType } from '../../shared/models/activitypub' 2import { ActivityPubActorType } from '../../shared/models/activitypub'
3import { SERVER_ACTOR_NAME } from '../initializers/constants' 3import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'
4import { AccountModel } from '../models/account/account' 4import { AccountModel } from '../models/account/account'
5import { UserModel } from '../models/account/user' 5import { UserModel } from '../models/account/user'
6import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub' 6import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub'
@@ -12,6 +12,8 @@ import { UserNotificationSetting, UserNotificationSettingValue } from '../../sha
12import { createWatchLaterPlaylist } from './video-playlist' 12import { createWatchLaterPlaylist } from './video-playlist'
13import { sequelizeTypescript } from '../initializers/database' 13import { sequelizeTypescript } from '../initializers/database'
14import { Transaction } from 'sequelize/types' 14import { Transaction } from 'sequelize/types'
15import { Redis } from './redis'
16import { Emailer } from './emailer'
15 17
16type ChannelNames = { name: string, displayName: string } 18type ChannelNames = { name: string, displayName: string }
17async function createUserAccountAndChannelAndPlaylist (parameters: { 19async function createUserAccountAndChannelAndPlaylist (parameters: {
@@ -100,12 +102,24 @@ async function createApplicationActor (applicationId: number) {
100 return accountCreated 102 return accountCreated
101} 103}
102 104
105async 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
105export { 118export {
106 createApplicationActor, 119 createApplicationActor,
107 createUserAccountAndChannelAndPlaylist, 120 createUserAccountAndChannelAndPlaylist,
108 createLocalAccountWithoutKeys 121 createLocalAccountWithoutKeys,
122 sendVerifyUserEmail
109} 123}
110 124
111// --------------------------------------------------------------------------- 125// ---------------------------------------------------------------------------