|
|
@ -40,6 +40,7 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private timer: any;
|
|
|
|
private timer: any;
|
|
|
|
|
|
|
|
private pinTimer: any;
|
|
|
|
|
|
|
|
|
|
|
|
private errorBody: string;
|
|
|
|
private errorBody: string;
|
|
|
|
private errorValidation: string;
|
|
|
|
private errorValidation: string;
|
|
|
@ -124,18 +125,35 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
public oauth() {
|
|
|
|
public oauth() {
|
|
|
|
this.authService.login({usePlexOAuth: true, password:"",rememberMe:true,username:""}).subscribe(x => {
|
|
|
|
this.authService.login({usePlexOAuth: true, password:"",rememberMe:true,username:""}).subscribe(x => {
|
|
|
|
if (window.frameElement) {
|
|
|
|
|
|
|
|
// in frame
|
|
|
|
|
|
|
|
window.open(x.url, "_blank");
|
|
|
|
window.open(x.url, "_blank");
|
|
|
|
} else {
|
|
|
|
this.pinTimer = setInterval(() => {
|
|
|
|
// not in frame
|
|
|
|
this.getPinResult(x.pinId);
|
|
|
|
window.location.href = x.url;
|
|
|
|
}, 10000);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public getPinResult(pinId: number) {
|
|
|
|
|
|
|
|
this.authService.oAuth(pinId).subscribe(x => {
|
|
|
|
|
|
|
|
if(x.access_token) {
|
|
|
|
|
|
|
|
localStorage.setItem("id_token", x.access_token);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.authService.loggedIn()) {
|
|
|
|
|
|
|
|
this.router.navigate(["search"]);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, err => {
|
|
|
|
|
|
|
|
this.notify.error(err.statusText);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.router.navigate(["login"]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
public ngOnDestroy() {
|
|
|
|
clearInterval(this.timer);
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
|
|
|
clearInterval(this.pinTimer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private cycleBackground() {
|
|
|
|
private cycleBackground() {
|
|
|
|