aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-users
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-01-19 09:29:47 +0100
committerChocobozzz <chocobozzz@cpy.re>2023-01-19 13:53:40 +0100
commit9589907c89d29a6c0acd52c8cb789af9f93ce9af (patch)
treef1d238e6144231bbfbed5614e05a21eca8aa6fc2 /client/src/app/shared/shared-users
parentb379759f55a35837b803a3b988674972db2903d1 (diff)
downloadPeerTube-9589907c89d29a6c0acd52c8cb789af9f93ce9af.tar.gz
PeerTube-9589907c89d29a6c0acd52c8cb789af9f93ce9af.tar.zst
PeerTube-9589907c89d29a6c0acd52c8cb789af9f93ce9af.zip
Implement signup approval in client
Diffstat (limited to 'client/src/app/shared/shared-users')
-rw-r--r--client/src/app/shared/shared-users/index.ts1
-rw-r--r--client/src/app/shared/shared-users/shared-users.module.ts3
-rw-r--r--client/src/app/shared/shared-users/user-signup.service.ts56
3 files changed, 0 insertions, 60 deletions
diff --git a/client/src/app/shared/shared-users/index.ts b/client/src/app/shared/shared-users/index.ts
index 20e60486d..95d90e49e 100644
--- a/client/src/app/shared/shared-users/index.ts
+++ b/client/src/app/shared/shared-users/index.ts
@@ -1,5 +1,4 @@
1export * from './user-admin.service' 1export * from './user-admin.service'
2export * from './user-signup.service'
3export * from './two-factor.service' 2export * from './two-factor.service'
4 3
5export * from './shared-users.module' 4export * from './shared-users.module'
diff --git a/client/src/app/shared/shared-users/shared-users.module.ts b/client/src/app/shared/shared-users/shared-users.module.ts
index 5a1675dc9..efffc6026 100644
--- a/client/src/app/shared/shared-users/shared-users.module.ts
+++ b/client/src/app/shared/shared-users/shared-users.module.ts
@@ -1,9 +1,7 @@
1
2import { NgModule } from '@angular/core' 1import { NgModule } from '@angular/core'
3import { SharedMainModule } from '../shared-main/shared-main.module' 2import { SharedMainModule } from '../shared-main/shared-main.module'
4import { TwoFactorService } from './two-factor.service' 3import { TwoFactorService } from './two-factor.service'
5import { UserAdminService } from './user-admin.service' 4import { UserAdminService } from './user-admin.service'
6import { UserSignupService } from './user-signup.service'
7 5
8@NgModule({ 6@NgModule({
9 imports: [ 7 imports: [
@@ -15,7 +13,6 @@ import { UserSignupService } from './user-signup.service'
15 exports: [], 13 exports: [],
16 14
17 providers: [ 15 providers: [
18 UserSignupService,
19 UserAdminService, 16 UserAdminService,
20 TwoFactorService 17 TwoFactorService
21 ] 18 ]
diff --git a/client/src/app/shared/shared-users/user-signup.service.ts b/client/src/app/shared/shared-users/user-signup.service.ts
deleted file mode 100644
index 46fe34af1..000000000
--- a/client/src/app/shared/shared-users/user-signup.service.ts
+++ /dev/null
@@ -1,56 +0,0 @@
1import { catchError, tap } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core'
4import { RestExtractor, UserService } from '@app/core'
5import { UserRegister } from '@shared/models'
6
7@Injectable()
8export class UserSignupService {
9 constructor (
10 private authHttp: HttpClient,
11 private restExtractor: RestExtractor,
12 private userService: UserService
13 ) { }
14
15 signup (userCreate: UserRegister) {
16 return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate)
17 .pipe(
18 tap(() => this.userService.setSignupInThisSession(true)),
19 catchError(err => this.restExtractor.handleError(err))
20 )
21 }
22
23 verifyEmail (userId: number, verificationString: string, isPendingEmail: boolean) {
24 const url = `${UserService.BASE_USERS_URL}/${userId}/verify-email`
25 const body = {
26 verificationString,
27 isPendingEmail
28 }
29
30 return this.authHttp.post(url, body)
31 .pipe(catchError(res => this.restExtractor.handleError(res)))
32 }
33
34 askSendVerifyEmail (email: string) {
35 const url = UserService.BASE_USERS_URL + '/ask-send-verify-email'
36
37 return this.authHttp.post(url, { email })
38 .pipe(catchError(err => this.restExtractor.handleError(err)))
39 }
40
41 getNewUsername (oldDisplayName: string, newDisplayName: string, currentUsername: string) {
42 // Don't update display name, the user seems to have changed it
43 if (this.displayNameToUsername(oldDisplayName) !== currentUsername) return currentUsername
44
45 return this.displayNameToUsername(newDisplayName)
46 }
47
48 private displayNameToUsername (displayName: string) {
49 if (!displayName) return ''
50
51 return displayName
52 .toLowerCase()
53 .replace(/\s/g, '_')
54 .replace(/[^a-z0-9_.]/g, '')
55 }
56}