|
|
|
@ -40,6 +40,7 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private timer: any;
|
|
|
|
|
private pinTimer: any;
|
|
|
|
|
private clientId: string;
|
|
|
|
|
|
|
|
|
|
private errorBody: string;
|
|
|
|
@ -128,14 +129,30 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|
|
|
|
this.plexTv.GetPin(this.clientId, this.appName).subscribe((pin: any) => {
|
|
|
|
|
|
|
|
|
|
this.authService.login({ usePlexOAuth: true, password: "", rememberMe: true, username: "", plexTvPin: pin }).subscribe(x => {
|
|
|
|
|
if (window.frameElement) {
|
|
|
|
|
// in frame
|
|
|
|
|
|
|
|
|
|
window.open(x.url, "_blank");
|
|
|
|
|
} else {
|
|
|
|
|
// not in frame
|
|
|
|
|
window.location.href = x.url;
|
|
|
|
|
}
|
|
|
|
|
this.pinTimer = setInterval(() => {
|
|
|
|
|
this.getPinResult(x.pinId);
|
|
|
|
|
}, 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"]);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|