|
|
|
@ -30,6 +30,7 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|
|
|
|
public landingFlag: boolean;
|
|
|
|
|
public baseUrl: string;
|
|
|
|
|
public loginWithOmbi: boolean;
|
|
|
|
|
public pinTimer: any;
|
|
|
|
|
|
|
|
|
|
public get appName(): string {
|
|
|
|
|
if (this.customizationSettings.applicationName) {
|
|
|
|
@ -115,6 +116,7 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|
|
|
|
localStorage.setItem("id_token", x.access_token);
|
|
|
|
|
|
|
|
|
|
if (this.authService.loggedIn()) {
|
|
|
|
|
this.ngOnDestroy();
|
|
|
|
|
this.router.navigate(["search"]);
|
|
|
|
|
} else {
|
|
|
|
|
this.notify.error(this.errorBody);
|
|
|
|
@ -128,19 +130,46 @@ 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.open(x.url, "_blank", `toolbar=0,
|
|
|
|
|
location=0,
|
|
|
|
|
status=0,
|
|
|
|
|
menubar=0,
|
|
|
|
|
scrollbars=1,
|
|
|
|
|
resizable=1,
|
|
|
|
|
width=500,
|
|
|
|
|
height=500`);
|
|
|
|
|
|
|
|
|
|
this.pinTimer = setInterval(() => {
|
|
|
|
|
this.notify.info("Authenticating", "Loading... Please Wait");
|
|
|
|
|
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.ngOnDestroy();
|
|
|
|
|
this.router.navigate(["search"]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}, err => {
|
|
|
|
|
this.notify.error(err.statusText);
|
|
|
|
|
|
|
|
|
|
this.router.navigate(["login"]);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
clearInterval(this.pinTimer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private cycleBackground() {
|
|
|
|
|