]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/menu/menu.component.ts
Redirect to default login url on 401
[github/Chocobozzz/PeerTube.git] / client / src / app / menu / menu.component.ts
index 97f07c956edcb8d612f05dfa604cd06150ba802c..568cb98bb2e9950b19126192af44fded2796078e 100644 (file)
@@ -1,6 +1,7 @@
 import { HotkeysService } from 'angular2-hotkeys'
 import * as debug from 'debug'
 import { switchMap } from 'rxjs/operators'
+import { environment } from 'src/environments/environment'
 import { ViewportScroller } from '@angular/common'
 import { Component, OnInit, ViewChild } from '@angular/core'
 import { Router } from '@angular/router'
@@ -21,9 +22,10 @@ import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
 import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component'
 import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service'
 import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
+import { PluginsManager } from '@root-helpers/plugins-manager'
 import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models'
 
-const logger = debug('peertube:menu:MenuComponent')
+const debugLogger = debug('peertube:menu:MenuComponent')
 
 @Component({
   selector: 'my-menu',
@@ -129,6 +131,10 @@ export class MenuComponent implements OnInit {
       .subscribe(() => this.openQuickSettings())
   }
 
+  getExternalLoginHref () {
+    return PluginsManager.getDefaultLoginHref(environment.apiUrl, this.serverConfig)
+  }
+
   isRegistrationAllowed () {
     if (!this.serverConfig) return false
 
@@ -186,9 +192,9 @@ export class MenuComponent implements OnInit {
 
   toggleUseP2P () {
     if (!this.user) return
-    this.user.webTorrentEnabled = !this.user.webTorrentEnabled
+    this.user.p2pEnabled = !this.user.p2pEnabled
 
-    this.userService.updateMyProfile({ webTorrentEnabled: this.user.webTorrentEnabled })
+    this.userService.updateMyProfile({ p2pEnabled: this.user.p2pEnabled })
       .subscribe(() => this.authService.refreshUserInformation())
   }
 
@@ -285,8 +291,8 @@ export class MenuComponent implements OnInit {
       .pipe(
         switchMap(() => this.user.computeCanSeeVideosLink(this.userService.getMyVideoQuotaUsed()))
       ).subscribe(res => {
-        if (res === true) logger('User can see videos link.')
-        else logger('User cannot see videos link.')
+        if (res === true) debugLogger('User can see videos link.')
+        else debugLogger('User cannot see videos link.')
       })
   }