mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Making the login works without the need of a reload
This commit is contained in:
parent
04944c5164
commit
81b30950e3
@ -26,7 +26,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<ng-template #accountDrop>
|
<ng-template #accountDrop>
|
||||||
<li #accountParent class="nav-item icon" style="opacity: 1 !important;">
|
<li #accountParent class="nav-item icon" style="opacity: 1 !important;">
|
||||||
<img matRipple [src]="authManager.user.picture" [matMenuTriggerFor]="accountMenu" class="profilePicture" matTooltipPosition="below" [matTooltip]="authManager.user.name" fallback="more.svg" (error)="accountParent.style.removeProperty('opacity');" />
|
<img matRipple [src]="authManager.user.picture" [matMenuTriggerFor]="accountMenu" class="profilePicture" matTooltipPosition="below" [matTooltip]="authManager.user.username" fallback="more.svg" (error)="accountParent.style.removeProperty('opacity');" />
|
||||||
</li>
|
</li>
|
||||||
<mat-menu #accountMenu="matMenu">
|
<mat-menu #accountMenu="matMenu">
|
||||||
<button class="dropButton" mat-menu-item (click)="this.openAccountDialog()">Settings</button>
|
<button class="dropButton" mat-menu-item (click)="this.openAccountDialog()">Settings</button>
|
||||||
|
@ -17,7 +17,6 @@ export class AppComponent
|
|||||||
{
|
{
|
||||||
libraries: Library[];
|
libraries: Library[];
|
||||||
isLoading: boolean = false;
|
isLoading: boolean = false;
|
||||||
account: Account;
|
|
||||||
|
|
||||||
constructor(private http: HttpClient, private router: Router, private location: Location, private authManager: AuthService, public dialog: MatDialog)
|
constructor(private http: HttpClient, private router: Router, private location: Location, private authManager: AuthService, public dialog: MatDialog)
|
||||||
{
|
{
|
||||||
@ -47,8 +46,6 @@ export class AppComponent
|
|||||||
|
|
||||||
if (!navigator.userAgent.match(/Mobi/))
|
if (!navigator.userAgent.match(/Mobi/))
|
||||||
document.body.classList.add("hoverEnabled");
|
document.body.classList.add("hoverEnabled");
|
||||||
|
|
||||||
this.account = this.authManager.getAccount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openSearch()
|
openSearch()
|
||||||
@ -81,11 +78,10 @@ export class AppComponent
|
|||||||
|
|
||||||
openAccountDialog()
|
openAccountDialog()
|
||||||
{
|
{
|
||||||
const dialog = this.dialog.open(AccountComponent, {width: "500px", data: this.account});
|
const dialog = this.dialog.open(AccountComponent, {width: "500px", data: this.authManager.getAccount()});
|
||||||
dialog.afterClosed().subscribe((result: Account) =>
|
dialog.afterClosed().subscribe((result: Account) =>
|
||||||
{
|
{
|
||||||
if (result)
|
this.authManager.getUser();
|
||||||
this.account = result;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,17 @@ export class AuthService
|
|||||||
this.isAuthenticated = auth;
|
this.isAuthenticated = auth;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.oidcSecurityService.getUserData().subscribe(userData =>
|
this.getUser();
|
||||||
{
|
|
||||||
this.user = userData;
|
|
||||||
console.log("Got user data:");
|
|
||||||
console.log(this.user);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUser()
|
||||||
|
{
|
||||||
|
this.oidcSecurityService.getUserData().subscribe(userData =>
|
||||||
|
{
|
||||||
|
this.user = userData;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
login()
|
login()
|
||||||
{
|
{
|
||||||
this.oidcSecurityService.authorize();
|
this.oidcSecurityService.authorize();
|
||||||
@ -56,8 +59,6 @@ export class AuthService
|
|||||||
{
|
{
|
||||||
if (!this.isAuthenticated)
|
if (!this.isAuthenticated)
|
||||||
return null;
|
return null;
|
||||||
console.log("Running get account");
|
|
||||||
console.log(this.user);
|
|
||||||
return {email: this.user.email, username: this.user.username, picture: this.user.picture};
|
return {email: this.user.email, username: this.user.username, picture: this.user.picture};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user