aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils
diff options
context:
space:
mode:
authorJosh Morel <morel.josh@hotmail.com>2018-08-31 03:18:19 -0400
committerChocobozzz <me@florianbigard.com>2018-08-31 09:18:19 +0200
commitd9eaee3939bf2e93e5d775d32bce77842201faba (patch)
treec115acb3611986b98f51b3addf29ebe66f63ee7f /server/tests/utils
parent04291e1ba44032165388758e993d385a10c1c5a1 (diff)
downloadPeerTube-d9eaee3939bf2e93e5d775d32bce77842201faba.tar.gz
PeerTube-d9eaee3939bf2e93e5d775d32bce77842201faba.tar.zst
PeerTube-d9eaee3939bf2e93e5d775d32bce77842201faba.zip
add user account email verificiation (#977)
* add user account email verificiation includes server and client code to: * enable verificationRequired via custom config * send verification email with registration * ask for verification email * verify via email * prevent login if not verified and required * conditional client links to ask for new verification email * allow login for verified=null these are users created when verification not required should still be able to login when verification is enabled * refactor email verifcation pr * change naming from verified to emailVerified * change naming from askVerifyEmail to askSendVerifyEmail * undo unrelated automatic prettier formatting on api/config * use redirectService for home * remove redundant success notification on email verified * revert test.yaml smpt host
Diffstat (limited to 'server/tests/utils')
-rw-r--r--server/tests/utils/server/config.ts3
-rw-r--r--server/tests/utils/users/users.ts26
2 files changed, 27 insertions, 2 deletions
diff --git a/server/tests/utils/server/config.ts b/server/tests/utils/server/config.ts
index 799c31ae5..b85e02ab7 100644
--- a/server/tests/utils/server/config.ts
+++ b/server/tests/utils/server/config.ts
@@ -74,7 +74,8 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) {
74 }, 74 },
75 signup: { 75 signup: {
76 enabled: false, 76 enabled: false,
77 limit: 5 77 limit: 5,
78 requiresEmailVerification: false
78 }, 79 },
79 admin: { 80 admin: {
80 email: 'superadmin1@example.com' 81 email: 'superadmin1@example.com'
diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts
index 5dba34b69..cd1b07701 100644
--- a/server/tests/utils/users/users.ts
+++ b/server/tests/utils/users/users.ts
@@ -246,6 +246,28 @@ function resetPassword (url: string, userId: number, verificationString: string,
246 }) 246 })
247} 247}
248 248
249function askSendVerifyEmail (url: string, email: string) {
250 const path = '/api/v1/users/ask-send-verify-email'
251
252 return makePostBodyRequest({
253 url,
254 path,
255 fields: { email },
256 statusCodeExpected: 204
257 })
258}
259
260function verifyEmail (url: string, userId: number, verificationString: string, statusCodeExpected = 204) {
261 const path = '/api/v1/users/' + userId + '/verify-email'
262
263 return makePostBodyRequest({
264 url,
265 path,
266 fields: { verificationString },
267 statusCodeExpected
268 })
269}
270
249// --------------------------------------------------------------------------- 271// ---------------------------------------------------------------------------
250 272
251export { 273export {
@@ -265,5 +287,7 @@ export {
265 unblockUser, 287 unblockUser,
266 askResetPassword, 288 askResetPassword,
267 resetPassword, 289 resetPassword,
268 updateMyAvatar 290 updateMyAvatar,
291 askSendVerifyEmail,
292 verifyEmail
269} 293}