diff options
author | Chocobozzz <me@florianbigard.com> | 2019-05-29 14:39:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-29 14:39:49 +0200 |
commit | b247a132709eb212fef4f77c4912dc0ec108f36b (patch) | |
tree | b2700e6ed55e00cd213c44e8afdeea4c327ae904 /client/src/app/core | |
parent | 1d5342abc43df02cf0bd69b1e865c0f179182eef (diff) | |
download | PeerTube-b247a132709eb212fef4f77c4912dc0ec108f36b.tar.gz PeerTube-b247a132709eb212fef4f77c4912dc0ec108f36b.tar.zst PeerTube-b247a132709eb212fef4f77c4912dc0ec108f36b.zip |
Add success icon on registration
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/core.module.ts | 3 | ||||
-rw-r--r-- | client/src/app/core/routing/redirect.service.ts | 9 | ||||
-rw-r--r-- | client/src/app/core/routing/unlogged-guard.service.ts | 25 |
3 files changed, 36 insertions, 1 deletions
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts index d3e72afb4..06fa8fcf1 100644 --- a/client/src/app/core/core.module.ts +++ b/client/src/app/core/core.module.ts | |||
@@ -20,6 +20,7 @@ import { Notifier } from './notification' | |||
20 | import { MessageService } from 'primeng/api' | 20 | import { MessageService } from 'primeng/api' |
21 | import { UserNotificationSocket } from '@app/core/notification/user-notification-socket.service' | 21 | import { UserNotificationSocket } from '@app/core/notification/user-notification-socket.service' |
22 | import { ServerConfigResolver } from './routing/server-config-resolver.service' | 22 | import { ServerConfigResolver } from './routing/server-config-resolver.service' |
23 | import { UnloggedGuard } from '@app/core/routing/unlogged-guard.service' | ||
23 | 24 | ||
24 | @NgModule({ | 25 | @NgModule({ |
25 | imports: [ | 26 | imports: [ |
@@ -58,6 +59,8 @@ import { ServerConfigResolver } from './routing/server-config-resolver.service' | |||
58 | ThemeService, | 59 | ThemeService, |
59 | LoginGuard, | 60 | LoginGuard, |
60 | UserRightGuard, | 61 | UserRightGuard, |
62 | UnloggedGuard, | ||
63 | |||
61 | RedirectService, | 64 | RedirectService, |
62 | Notifier, | 65 | Notifier, |
63 | MessageService, | 66 | MessageService, |
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts index e1db4097b..571822b76 100644 --- a/client/src/app/core/routing/redirect.service.ts +++ b/client/src/app/core/routing/redirect.service.ts | |||
@@ -42,7 +42,14 @@ export class RedirectService { | |||
42 | } | 42 | } |
43 | 43 | ||
44 | redirectToPreviousRoute () { | 44 | redirectToPreviousRoute () { |
45 | if (this.previousUrl) return this.router.navigateByUrl(this.previousUrl) | 45 | const exceptions = [ |
46 | '/verify-account' | ||
47 | ] | ||
48 | |||
49 | if (this.previousUrl) { | ||
50 | const isException = exceptions.find(e => this.previousUrl.startsWith(e)) | ||
51 | if (!isException) return this.router.navigateByUrl(this.previousUrl) | ||
52 | } | ||
46 | 53 | ||
47 | return this.redirectToHomepage() | 54 | return this.redirectToHomepage() |
48 | } | 55 | } |
diff --git a/client/src/app/core/routing/unlogged-guard.service.ts b/client/src/app/core/routing/unlogged-guard.service.ts new file mode 100644 index 000000000..3132a1a77 --- /dev/null +++ b/client/src/app/core/routing/unlogged-guard.service.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router' | ||
3 | import { AuthService } from '../auth/auth.service' | ||
4 | import { RedirectService } from './redirect.service' | ||
5 | |||
6 | @Injectable() | ||
7 | export class UnloggedGuard implements CanActivate, CanActivateChild { | ||
8 | |||
9 | constructor ( | ||
10 | private router: Router, | ||
11 | private auth: AuthService, | ||
12 | private redirectService: RedirectService | ||
13 | ) {} | ||
14 | |||
15 | canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | ||
16 | if (this.auth.isLoggedIn() === false) return true | ||
17 | |||
18 | this.redirectService.redirectToHomepage() | ||
19 | return false | ||
20 | } | ||
21 | |||
22 | canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | ||
23 | return this.canActivate(route, state) | ||
24 | } | ||
25 | } | ||