mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Improved the Plex OAuth flow
This commit is contained in:
parent
f18aa778e6
commit
5d8a212312
1 changed files with 18 additions and 5 deletions
|
@ -146,6 +146,9 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|||
}
|
||||
|
||||
public oauth() {
|
||||
if (this.oAuthWindow) {
|
||||
this.oAuthWindow.close();
|
||||
}
|
||||
this.oAuthWindow = window.open(window.location.toString(), "_blank", `toolbar=0,
|
||||
location=0,
|
||||
status=0,
|
||||
|
@ -159,16 +162,22 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|||
this.authService.login({ usePlexOAuth: true, password: "", rememberMe: true, username: "", plexTvPin: pin }).subscribe(x => {
|
||||
this.oAuthWindow!.location.replace(x.url);
|
||||
|
||||
this.pinTimer = setInterval(() => {
|
||||
if (this.pinTimer) {
|
||||
clearInterval(this.pinTimer);
|
||||
}
|
||||
|
||||
this.oauthLoading = true;
|
||||
this.getPinResult(x.pinId);
|
||||
}, 4000);
|
||||
this.pinTimer = setInterval(() => {
|
||||
if(this.oAuthWindow.closed) {
|
||||
this.oauthLoading = true;
|
||||
this.getPinResult(x.pinId);
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public getPinResult(pinId: number) {
|
||||
clearInterval(this.pinTimer);
|
||||
this.authService.oAuth(pinId).subscribe(x => {
|
||||
if(x.access_token) {
|
||||
this.store.save("id_token", x.access_token);
|
||||
|
@ -176,7 +185,7 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|||
if (this.authService.loggedIn()) {
|
||||
this.ngOnDestroy();
|
||||
|
||||
if(this.oAuthWindow) {
|
||||
if (this.oAuthWindow) {
|
||||
this.oAuthWindow.close();
|
||||
}
|
||||
this.oauthLoading = false;
|
||||
|
@ -184,6 +193,10 @@ export class LoginComponent implements OnDestroy, OnInit {
|
|||
return;
|
||||
}
|
||||
}
|
||||
this.notify.open("Could not log you in!", "OK", {
|
||||
duration: 3000
|
||||
});
|
||||
this.oauthLoading = false;
|
||||
|
||||
}, err => {
|
||||
console.log(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue