aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-02-14 11:47:01 +0100
committerChocobozzz <me@florianbigard.com>2023-02-14 11:51:44 +0100
commit98bd5e2256bfdeba6d5ab07f0421acfde1a0de26 (patch)
treea1193f1af10f0da7a532d4aa6d5045e51c3d16a9
parent4ea827076df39935375d66fffb5e1e27e667111e (diff)
downloadPeerTube-98bd5e2256bfdeba6d5ab07f0421acfde1a0de26.tar.gz
PeerTube-98bd5e2256bfdeba6d5ab07f0421acfde1a0de26.tar.zst
PeerTube-98bd5e2256bfdeba6d5ab07f0421acfde1a0de26.zip
Refactor login redirection/button links
Correctly handle external auth redirection in all cases
-rw-r--r--client/src/app/+error-page/error-page.component.html5
-rw-r--r--client/src/app/+error-page/error-page.module.ts2
-rw-r--r--client/src/app/+reset-password/reset-password.component.ts1
-rw-r--r--client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts2
-rw-r--r--client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html5
-rw-r--r--client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts7
-rw-r--r--client/src/app/core/auth/auth.service.ts10
-rw-r--r--client/src/app/core/routing/login-guard.service.ts9
-rw-r--r--client/src/app/core/routing/redirect.service.ts9
-rw-r--r--client/src/app/core/routing/user-right-guard.service.ts7
-rw-r--r--client/src/app/menu/menu.component.html3
-rw-r--r--client/src/app/menu/menu.component.scss3
-rw-r--r--client/src/app/menu/menu.component.ts6
-rw-r--r--client/src/app/shared/shared-main/angular/index.ts1
-rw-r--r--client/src/app/shared/shared-main/angular/link.component.html4
-rw-r--r--client/src/app/shared/shared-main/angular/link.component.scss2
-rw-r--r--client/src/app/shared/shared-main/angular/link.component.ts16
-rw-r--r--client/src/app/shared/shared-main/angular/login-link.component.html1
-rw-r--r--client/src/app/shared/shared-main/angular/login-link.component.ts22
-rw-r--r--client/src/app/shared/shared-main/shared-main.module.ts3
-rw-r--r--client/src/app/shared/shared-user-subscription/subscribe-button.component.ts7
21 files changed, 77 insertions, 48 deletions
diff --git a/client/src/app/+error-page/error-page.component.html b/client/src/app/+error-page/error-page.component.html
index 070985d3c..b8b9296a3 100644
--- a/client/src/app/+error-page/error-page.component.html
+++ b/client/src/app/+error-page/error-page.component.html
@@ -31,10 +31,7 @@
31 <ng-container *ngIf="type !== 'video'" i18n>You might need to login to see the resource.</ng-container> 31 <ng-container *ngIf="type !== 'video'" i18n>You might need to login to see the resource.</ng-container>
32 </div> 32 </div>
33 33
34 <a class="peertube-button-big-link orange-button mt-5" i18n routerLink="/login"> 34 <my-login-link className="peertube-button-big-link orange-button mt-5"></my-login-link>
35 Login
36 </a>
37
38 </div> 35 </div>
39 36
40 <div *ngIf="status === 403" class="box"> 37 <div *ngIf="status === 403" class="box">
diff --git a/client/src/app/+error-page/error-page.module.ts b/client/src/app/+error-page/error-page.module.ts
index 807c6f5a9..34f026ea8 100644
--- a/client/src/app/+error-page/error-page.module.ts
+++ b/client/src/app/+error-page/error-page.module.ts
@@ -1,11 +1,13 @@
1import { CommonModule } from '@angular/common' 1import { CommonModule } from '@angular/common'
2import { NgModule } from '@angular/core' 2import { NgModule } from '@angular/core'
3import { SharedMainModule } from '@app/shared/shared-main'
3import { ErrorPageRoutingModule } from './error-page-routing.module' 4import { ErrorPageRoutingModule } from './error-page-routing.module'
4import { ErrorPageComponent } from './error-page.component' 5import { ErrorPageComponent } from './error-page.component'
5 6
6@NgModule({ 7@NgModule({
7 imports: [ 8 imports: [
8 CommonModule, 9 CommonModule,
10 SharedMainModule,
9 11
10 ErrorPageRoutingModule 12 ErrorPageRoutingModule
11 ], 13 ],
diff --git a/client/src/app/+reset-password/reset-password.component.ts b/client/src/app/+reset-password/reset-password.component.ts
index 44216f978..a6c05bbfb 100644
--- a/client/src/app/+reset-password/reset-password.component.ts
+++ b/client/src/app/+reset-password/reset-password.component.ts
@@ -45,6 +45,7 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
45 .subscribe({ 45 .subscribe({
46 next: () => { 46 next: () => {
47 this.notifier.success($localize`Your password has been successfully reset!`) 47 this.notifier.success($localize`Your password has been successfully reset!`)
48
48 this.router.navigate([ '/login' ]) 49 this.router.navigate([ '/login' ])
49 }, 50 },
50 51
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts b/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts
index 0fef246b3..d0c138834 100644
--- a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts
@@ -82,7 +82,7 @@ export class VideoRateComponent implements OnInit, OnChanges, OnDestroy {
82 getRatePopoverText () { 82 getRatePopoverText () {
83 if (this.isUserLoggedIn) return undefined 83 if (this.isUserLoggedIn) return undefined
84 84
85 return $localize`You need to be <a href="/login">logged in</a> to rate this video.` 85 return $localize`You need to be logged in to rate this video.`
86 } 86 }
87 87
88 private checkUserRating () { 88 private checkUserRating () {
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html
index 6bc201f32..203e9ce62 100644
--- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html
+++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html
@@ -74,10 +74,7 @@
74 (click)="hideModals()" (key.enter)="hideModals()" 74 (click)="hideModals()" (key.enter)="hideModals()"
75 > 75 >
76 76
77 <input 77 <my-login-link i18n-label label="Login to comment" className="peertube-button-link orange-button"></my-login-link>
78 type="submit" i18n-value value="Login to comment" class="peertube-button orange-button"
79 (click)="gotoLogin()"
80 >
81 </div> 78 </div>
82</ng-template> 79</ng-template>
83 80
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts
index 9a9bfe710..033097084 100644
--- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts
@@ -13,7 +13,6 @@ import {
13 SimpleChanges, 13 SimpleChanges,
14 ViewChild 14 ViewChild
15} from '@angular/core' 15} from '@angular/core'
16import { Router } from '@angular/router'
17import { Notifier, User } from '@app/core' 16import { Notifier, User } from '@app/core'
18import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators' 17import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators'
19import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' 18import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
@@ -52,7 +51,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
52 private notifier: Notifier, 51 private notifier: Notifier,
53 private videoCommentService: VideoCommentService, 52 private videoCommentService: VideoCommentService,
54 private modalService: NgbModal, 53 private modalService: NgbModal,
55 private router: Router,
56 @Inject(LOCALE_ID) private localeId: string 54 @Inject(LOCALE_ID) private localeId: string
57 ) { 55 ) {
58 super() 56 super()
@@ -161,11 +159,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
161 return window.location.href 159 return window.location.href
162 } 160 }
163 161
164 gotoLogin () {
165 this.hideModals()
166 this.router.navigate([ '/login' ])
167 }
168
169 cancelCommentReply () { 162 cancelCommentReply () {
170 this.cancel.emit(null) 163 this.cancel.emit(null)
171 this.form.value['text'] = this.textareaElement.nativeElement.value = '' 164 this.form.value['text'] = this.textareaElement.nativeElement.value = ''
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index ed7eabb76..6fe601d8d 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -5,11 +5,11 @@ import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular
5import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
6import { Router } from '@angular/router' 6import { Router } from '@angular/router'
7import { Notifier } from '@app/core/notification/notifier.service' 7import { Notifier } from '@app/core/notification/notifier.service'
8import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage, PluginsManager } from '@root-helpers/index' 8import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index'
9import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' 9import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models'
10import { environment } from '../../../environments/environment' 10import { environment } from '../../../environments/environment'
11import { RestExtractor } from '../rest/rest-extractor.service' 11import { RestExtractor } from '../rest/rest-extractor.service'
12import { ServerService } from '../server' 12import { RedirectService } from '../routing'
13import { AuthStatus } from './auth-status.model' 13import { AuthStatus } from './auth-status.model'
14import { AuthUser } from './auth-user.model' 14import { AuthUser } from './auth-user.model'
15 15
@@ -45,7 +45,7 @@ export class AuthService {
45 private refreshingTokenObservable: Observable<any> 45 private refreshingTokenObservable: Observable<any>
46 46
47 constructor ( 47 constructor (
48 private serverService: ServerService, 48 private redirectService: RedirectService,
49 private http: HttpClient, 49 private http: HttpClient,
50 private notifier: Notifier, 50 private notifier: Notifier,
51 private hotkeysService: HotkeysService, 51 private hotkeysService: HotkeysService,
@@ -227,9 +227,7 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular
227 logger.info('Cannot refresh token -> logout...') 227 logger.info('Cannot refresh token -> logout...')
228 this.logout() 228 this.logout()
229 229
230 const externalLoginUrl = PluginsManager.getDefaultLoginHref(environment.apiUrl, this.serverService.getHTMLConfig()) 230 this.redirectService.redirectToLogin()
231 if (externalLoginUrl) window.location.href = externalLoginUrl
232 else this.router.navigate([ '/login' ])
233 231
234 return observableThrowError(() => ({ 232 return observableThrowError(() => ({
235 error: $localize`You need to reconnect.` 233 error: $localize`You need to reconnect.`
diff --git a/client/src/app/core/routing/login-guard.service.ts b/client/src/app/core/routing/login-guard.service.ts
index a949be14c..2f5a31e7f 100644
--- a/client/src/app/core/routing/login-guard.service.ts
+++ b/client/src/app/core/routing/login-guard.service.ts
@@ -1,19 +1,20 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router' 2import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router'
3import { AuthService } from '../auth/auth.service' 3import { AuthService } from '../auth/auth.service'
4import { RedirectService } from './redirect.service'
4 5
5@Injectable() 6@Injectable()
6export class LoginGuard implements CanActivate, CanActivateChild { 7export class LoginGuard implements CanActivate, CanActivateChild {
7 8
8 constructor ( 9 constructor (
9 private router: Router, 10 private auth: AuthService,
10 private auth: AuthService 11 private redirectService: RedirectService
11 ) {} 12 ) {}
12 13
13 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { 14 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
14 if (this.auth.isLoggedIn() === true) return true 15 if (this.auth.isLoggedIn() === true) return true
15 16
16 this.router.navigate([ '/login' ]) 17 this.redirectService.redirectToLogin()
17 return false 18 return false
18 } 19 }
19 20
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts
index 1344458d5..e239c6210 100644
--- a/client/src/app/core/routing/redirect.service.ts
+++ b/client/src/app/core/routing/redirect.service.ts
@@ -4,6 +4,8 @@ import { NavigationCancel, NavigationEnd, Router } from '@angular/router'
4import { logger } from '@root-helpers/logger' 4import { logger } from '@root-helpers/logger'
5import { ServerService } from '../server' 5import { ServerService } from '../server'
6import { SessionStorageService } from '../wrappers/storage.service' 6import { SessionStorageService } from '../wrappers/storage.service'
7import { PluginsManager } from '@root-helpers/plugins-manager'
8import { environment } from 'src/environments/environment'
7 9
8const debugLogger = debug('peertube:router:RedirectService') 10const debugLogger = debug('peertube:router:RedirectService')
9 11
@@ -100,6 +102,13 @@ export class RedirectService {
100 102
101 } 103 }
102 104
105 redirectToLogin () {
106 const externalLoginUrl = PluginsManager.getDefaultLoginHref(environment.apiUrl, this.serverService.getHTMLConfig())
107
108 if (externalLoginUrl) window.location.href = externalLoginUrl
109 else this.router.navigate([ '/login' ])
110 }
111
103 private doRedirect (redirectUrl: string, fallbackRoute?: string) { 112 private doRedirect (redirectUrl: string, fallbackRoute?: string) {
104 debugLogger('Redirecting on %s', redirectUrl) 113 debugLogger('Redirecting on %s', redirectUrl)
105 114
diff --git a/client/src/app/core/routing/user-right-guard.service.ts b/client/src/app/core/routing/user-right-guard.service.ts
index a2ce772db..c6bd05bb6 100644
--- a/client/src/app/core/routing/user-right-guard.service.ts
+++ b/client/src/app/core/routing/user-right-guard.service.ts
@@ -1,12 +1,13 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router' 2import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router'
3import { AuthService } from '../auth/auth.service' 3import { AuthService } from '../auth/auth.service'
4import { RedirectService } from './redirect.service'
4 5
5@Injectable() 6@Injectable()
6export class UserRightGuard implements CanActivate, CanActivateChild { 7export class UserRightGuard implements CanActivate, CanActivateChild {
7 8
8 constructor ( 9 constructor (
9 private router: Router, 10 private redirectService: RedirectService,
10 private auth: AuthService 11 private auth: AuthService
11 ) {} 12 ) {}
12 13
@@ -18,7 +19,7 @@ export class UserRightGuard implements CanActivate, CanActivateChild {
18 if (user.hasRight(neededUserRight)) return true 19 if (user.hasRight(neededUserRight)) return true
19 } 20 }
20 21
21 this.router.navigate([ '/login' ]) 22 this.redirectService.redirectToLogin()
22 return false 23 return false
23 } 24 }
24 25
diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html
index abfc151e7..0fb9897b9 100644
--- a/client/src/app/menu/menu.component.html
+++ b/client/src/app/menu/menu.component.html
@@ -100,8 +100,7 @@
100 </div> 100 </div>
101 101
102 <div *ngIf="!isLoggedIn" class="login-buttons-block"> 102 <div *ngIf="!isLoggedIn" class="login-buttons-block">
103 <a i18n *ngIf="!getExternalLoginHref()" routerLink="/login" class="peertube-button-link orange-button">Login</a> 103 <my-login-link className="peertube-button-link orange-button w-100"></my-login-link>
104 <a i18n *ngIf="getExternalLoginHref()" [href]="getExternalLoginHref()" class="peertube-button-link orange-button">Login</a>
105 104
106 <a *ngIf="isRegistrationAllowed()" routerLink="/signup" class="peertube-button-link create-account-button"> 105 <a *ngIf="isRegistrationAllowed()" routerLink="/signup" class="peertube-button-link create-account-button">
107 <my-signup-label [requiresApproval]="requiresApproval"></my-signup-label> 106 <my-signup-label [requiresApproval]="requiresApproval"></my-signup-label>
diff --git a/client/src/app/menu/menu.component.scss b/client/src/app/menu/menu.component.scss
index cd57e134e..9d5ad57c2 100644
--- a/client/src/app/menu/menu.component.scss
+++ b/client/src/app/menu/menu.component.scss
@@ -251,7 +251,8 @@ my-actor-avatar {
251.login-buttons-block { 251.login-buttons-block {
252 margin: 30px 25px 35px; 252 margin: 30px 25px 35px;
253 253
254 > a { 254 > a,
255 > my-login-link {
255 display: block; 256 display: block;
256 width: 100%; 257 width: 100%;
257 258
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index fc6d74cff..21354e52d 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -1,7 +1,6 @@
1import { HotkeysService } from 'angular2-hotkeys' 1import { HotkeysService } from 'angular2-hotkeys'
2import * as debug from 'debug' 2import * as debug from 'debug'
3import { switchMap } from 'rxjs/operators' 3import { switchMap } from 'rxjs/operators'
4import { environment } from 'src/environments/environment'
5import { ViewportScroller } from '@angular/common' 4import { ViewportScroller } from '@angular/common'
6import { Component, OnInit, ViewChild } from '@angular/core' 5import { Component, OnInit, ViewChild } from '@angular/core'
7import { Router } from '@angular/router' 6import { Router } from '@angular/router'
@@ -22,7 +21,6 @@ import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
22import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component' 21import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component'
23import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service' 22import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service'
24import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' 23import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
25import { PluginsManager } from '@root-helpers/plugins-manager'
26import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models' 24import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models'
27 25
28const debugLogger = debug('peertube:menu:MenuComponent') 26const debugLogger = debug('peertube:menu:MenuComponent')
@@ -135,10 +133,6 @@ export class MenuComponent implements OnInit {
135 .subscribe(() => this.openQuickSettings()) 133 .subscribe(() => this.openQuickSettings())
136 } 134 }
137 135
138 getExternalLoginHref () {
139 return PluginsManager.getDefaultLoginHref(environment.apiUrl, this.serverConfig)
140 }
141
142 isRegistrationAllowed () { 136 isRegistrationAllowed () {
143 if (!this.serverConfig) return false 137 if (!this.serverConfig) return false
144 138
diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts
index 4b87c2952..f72d60313 100644
--- a/client/src/app/shared/shared-main/angular/index.ts
+++ b/client/src/app/shared/shared-main/angular/index.ts
@@ -5,5 +5,6 @@ export * from './duration-formatter.pipe'
5export * from './from-now.pipe' 5export * from './from-now.pipe'
6export * from './infinite-scroller.directive' 6export * from './infinite-scroller.directive'
7export * from './link.component' 7export * from './link.component'
8export * from './login-link.component'
8export * from './number-formatter.pipe' 9export * from './number-formatter.pipe'
9export * from './peertube-template.directive' 10export * from './peertube-template.directive'
diff --git a/client/src/app/shared/shared-main/angular/link.component.html b/client/src/app/shared/shared-main/angular/link.component.html
index e61a1e085..2ea2df2b5 100644
--- a/client/src/app/shared/shared-main/angular/link.component.html
+++ b/client/src/app/shared/shared-main/angular/link.component.html
@@ -2,10 +2,10 @@
2 <ng-content></ng-content> 2 <ng-content></ng-content>
3</ng-template> 3</ng-template>
4 4
5<a *ngIf="!href" [routerLink]="internalLink" [attr.title]="title" [tabindex]="tabindex"> 5<a *ngIf="!href" [routerLink]="internalLink" [attr.title]="title" [tabindex]="tabindex" [ngClass]="builtClasses">
6 <ng-template *ngTemplateOutlet="content"></ng-template> 6 <ng-template *ngTemplateOutlet="content"></ng-template>
7</a> 7</a>
8 8
9<a *ngIf="href" [href]="href" [target]="target" [attr.title]="title" [tabindex]="tabindex"> 9<a *ngIf="href" [href]="href" [target]="target" [attr.title]="title" [tabindex]="tabindex" [ngClass]="builtClasses">
10 <ng-template *ngTemplateOutlet="content"></ng-template> 10 <ng-template *ngTemplateOutlet="content"></ng-template>
11</a> 11</a>
diff --git a/client/src/app/shared/shared-main/angular/link.component.scss b/client/src/app/shared/shared-main/angular/link.component.scss
index bb86d5488..f54240d31 100644
--- a/client/src/app/shared/shared-main/angular/link.component.scss
+++ b/client/src/app/shared/shared-main/angular/link.component.scss
@@ -1,4 +1,4 @@
1a { 1.no-class {
2 color: inherit; 2 color: inherit;
3 text-decoration: inherit; 3 text-decoration: inherit;
4 position: inherit; 4 position: inherit;
diff --git a/client/src/app/shared/shared-main/angular/link.component.ts b/client/src/app/shared/shared-main/angular/link.component.ts
index ecbd9151c..1f5975589 100644
--- a/client/src/app/shared/shared-main/angular/link.component.ts
+++ b/client/src/app/shared/shared-main/angular/link.component.ts
@@ -1,17 +1,27 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2 2
3@Component({ 3@Component({
4 selector: 'my-link', 4 selector: 'my-link',
5 styleUrls: [ './link.component.scss' ], 5 styleUrls: [ './link.component.scss' ],
6 templateUrl: './link.component.html' 6 templateUrl: './link.component.html'
7}) 7})
8export class LinkComponent { 8export class LinkComponent implements OnInit {
9 @Input() internalLink?: string | any[] 9 @Input() internalLink?: string | any[]
10 10
11 @Input() href?: string 11 @Input() href?: string
12 @Input() target?: string 12 @Input() target = '_self'
13 13
14 @Input() title?: string 14 @Input() title?: string
15 15
16 @Input() className?: string
17
16 @Input() tabindex: string | number 18 @Input() tabindex: string | number
19
20 builtClasses: string
21
22 ngOnInit () {
23 this.builtClasses = this.className
24 ? this.className
25 : 'no-class'
26 }
17} 27}
diff --git a/client/src/app/shared/shared-main/angular/login-link.component.html b/client/src/app/shared/shared-main/angular/login-link.component.html
new file mode 100644
index 000000000..f90ffba68
--- /dev/null
+++ b/client/src/app/shared/shared-main/angular/login-link.component.html
@@ -0,0 +1 @@
<my-link i18n internalLink="/login" [href]="getExternalLoginHref()" [className]="className">{{ label }}</my-link>
diff --git a/client/src/app/shared/shared-main/angular/login-link.component.ts b/client/src/app/shared/shared-main/angular/login-link.component.ts
new file mode 100644
index 000000000..7e3a773c2
--- /dev/null
+++ b/client/src/app/shared/shared-main/angular/login-link.component.ts
@@ -0,0 +1,22 @@
1import { environment } from 'src/environments/environment'
2import { Component, Input } from '@angular/core'
3import { ServerService } from '@app/core'
4import { PluginsManager } from '@root-helpers/plugins-manager'
5
6@Component({
7 selector: 'my-login-link',
8 templateUrl: './login-link.component.html'
9})
10export class LoginLinkComponent {
11 @Input() label = $localize`Login`
12
13 @Input() className?: string
14
15 constructor (private server: ServerService) {
16
17 }
18
19 getExternalLoginHref () {
20 return PluginsManager.getDefaultLoginHref(environment.apiUrl, this.server.getHTMLConfig())
21 }
22}
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts
index eb1642d97..0bdf27263 100644
--- a/client/src/app/shared/shared-main/shared-main.module.ts
+++ b/client/src/app/shared/shared-main/shared-main.module.ts
@@ -25,6 +25,7 @@ import {
25 FromNowPipe, 25 FromNowPipe,
26 InfiniteScrollerDirective, 26 InfiniteScrollerDirective,
27 LinkComponent, 27 LinkComponent,
28 LoginLinkComponent,
28 NumberFormatterPipe, 29 NumberFormatterPipe,
29 PeerTubeTemplateDirective 30 PeerTubeTemplateDirective
30} from './angular' 31} from './angular'
@@ -92,6 +93,7 @@ import { VideoChannelService } from './video-channel'
92 InfiniteScrollerDirective, 93 InfiniteScrollerDirective,
93 PeerTubeTemplateDirective, 94 PeerTubeTemplateDirective,
94 LinkComponent, 95 LinkComponent,
96 LoginLinkComponent,
95 97
96 ActionDropdownComponent, 98 ActionDropdownComponent,
97 ButtonComponent, 99 ButtonComponent,
@@ -152,6 +154,7 @@ import { VideoChannelService } from './video-channel'
152 InfiniteScrollerDirective, 154 InfiniteScrollerDirective,
153 PeerTubeTemplateDirective, 155 PeerTubeTemplateDirective,
154 LinkComponent, 156 LinkComponent,
157 LoginLinkComponent,
155 158
156 ActionDropdownComponent, 159 ActionDropdownComponent,
157 ButtonComponent, 160 ButtonComponent,
diff --git a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts
index 7a55a6ffb..a002bf4e7 100644
--- a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts
+++ b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts
@@ -1,7 +1,6 @@
1import { concat, forkJoin, merge } from 'rxjs' 1import { concat, forkJoin, merge } from 'rxjs'
2import { Component, Input, OnChanges, OnInit } from '@angular/core' 2import { Component, Input, OnChanges, OnInit } from '@angular/core'
3import { Router } from '@angular/router' 3import { AuthService, Notifier, RedirectService } from '@app/core'
4import { AuthService, Notifier } from '@app/core'
5import { Account, VideoChannel, VideoService } from '@app/shared/shared-main' 4import { Account, VideoChannel, VideoService } from '@app/shared/shared-main'
6import { FeedFormat } from '@shared/models' 5import { FeedFormat } from '@shared/models'
7import { UserSubscriptionService } from './user-subscription.service' 6import { UserSubscriptionService } from './user-subscription.service'
@@ -27,7 +26,7 @@ export class SubscribeButtonComponent implements OnInit, OnChanges {
27 26
28 constructor ( 27 constructor (
29 private authService: AuthService, 28 private authService: AuthService,
30 private router: Router, 29 private redirectService: RedirectService,
31 private notifier: Notifier, 30 private notifier: Notifier,
32 private userSubscriptionService: UserSubscriptionService, 31 private userSubscriptionService: UserSubscriptionService,
33 private videoService: VideoService 32 private videoService: VideoService
@@ -152,7 +151,7 @@ export class SubscribeButtonComponent implements OnInit, OnChanges {
152 } 151 }
153 152
154 gotoLogin () { 153 gotoLogin () {
155 this.router.navigate([ '/login' ]) 154 this.redirectService.redirectToLogin()
156 } 155 }
157 156
158 subscribeStatus (subscribed: boolean) { 157 subscribeStatus (subscribed: boolean) {