diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-29 10:42:35 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-05-04 16:21:39 +0200 |
commit | ebefc902f59be6c5542c19ff706e310d9dddf75f (patch) | |
tree | 79eb831217a7938484e191070d6a465bc07a00fd /client/src/app/login/login.component.ts | |
parent | 9107d791e2eef9a1b24b0499dac8b9dbba8a792f (diff) | |
download | PeerTube-ebefc902f59be6c5542c19ff706e310d9dddf75f.tar.gz PeerTube-ebefc902f59be6c5542c19ff706e310d9dddf75f.tar.zst PeerTube-ebefc902f59be6c5542c19ff706e310d9dddf75f.zip |
Add external login buttons
Diffstat (limited to 'client/src/app/login/login.component.ts')
-rw-r--r-- | client/src/app/login/login.component.ts | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index 9c8f5c52e..5db8d3dbb 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, OnInit, ViewChild, AfterViewInit } from '@angular/core' |
2 | import { Notifier, RedirectService } from '@app/core' | 2 | import { Notifier, RedirectService } from '@app/core' |
3 | import { UserService } from '@app/shared' | 3 | import { UserService } from '@app/shared' |
4 | import { AuthService } from '../core' | 4 | import { AuthService } from '../core' |
@@ -8,7 +8,8 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val | |||
8 | import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service' | 8 | import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service' |
9 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' | 9 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' |
10 | import { ActivatedRoute } from '@angular/router' | 10 | import { ActivatedRoute } from '@angular/router' |
11 | import { ServerConfig } from '@shared/models/server/server-config.model' | 11 | import { ServerConfig, RegisteredExternalAuthConfig } from '@shared/models/server/server-config.model' |
12 | import { environment } from 'src/environments/environment' | ||
12 | 13 | ||
13 | @Component({ | 14 | @Component({ |
14 | selector: 'my-login', | 15 | selector: 'my-login', |
@@ -16,13 +17,14 @@ import { ServerConfig } from '@shared/models/server/server-config.model' | |||
16 | styleUrls: [ './login.component.scss' ] | 17 | styleUrls: [ './login.component.scss' ] |
17 | }) | 18 | }) |
18 | 19 | ||
19 | export class LoginComponent extends FormReactive implements OnInit { | 20 | export class LoginComponent extends FormReactive implements OnInit, AfterViewInit { |
20 | @ViewChild('emailInput', { static: true }) input: ElementRef | 21 | @ViewChild('usernameInput', { static: false }) usernameInput: ElementRef |
21 | @ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef | 22 | @ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef |
22 | 23 | ||
23 | error: string = null | 24 | error: string = null |
24 | forgotPasswordEmail = '' | 25 | forgotPasswordEmail = '' |
25 | isAuthenticatedWithExternalAuth = false | 26 | isAuthenticatedWithExternalAuth = false |
27 | externalLogins: string[] = [] | ||
26 | 28 | ||
27 | private openedForgotPasswordModal: NgbModalRef | 29 | private openedForgotPasswordModal: NgbModalRef |
28 | private serverConfig: ServerConfig | 30 | private serverConfig: ServerConfig |
@@ -63,8 +65,20 @@ export class LoginComponent extends FormReactive implements OnInit { | |||
63 | username: this.loginValidatorsService.LOGIN_USERNAME, | 65 | username: this.loginValidatorsService.LOGIN_USERNAME, |
64 | password: this.loginValidatorsService.LOGIN_PASSWORD | 66 | password: this.loginValidatorsService.LOGIN_PASSWORD |
65 | }) | 67 | }) |
68 | } | ||
69 | |||
70 | ngAfterViewInit () { | ||
71 | if (this.usernameInput) { | ||
72 | this.usernameInput.nativeElement.focus() | ||
73 | } | ||
74 | } | ||
75 | |||
76 | getExternalLogins () { | ||
77 | return this.serverConfig.plugin.registeredExternalAuths | ||
78 | } | ||
66 | 79 | ||
67 | this.input.nativeElement.focus() | 80 | getAuthHref (auth: RegisteredExternalAuthConfig) { |
81 | return environment.apiUrl + `/plugins/${auth.name}/${auth.version}/auth/${auth.authName}` | ||
68 | } | 82 | } |
69 | 83 | ||
70 | login () { | 84 | login () { |