bugfix: restablecido el login
This commit is contained in:
@@ -23,8 +23,8 @@ export const authConfig: AuthConfig = {
|
||||
// Important: Request offline_access to get a refresh token
|
||||
// The api scope is a usecase specific one
|
||||
scope: useSilentRefreshForCodeFlow
|
||||
? 'openid profile email api'
|
||||
: 'openid profile email offline_access api',
|
||||
? 'openid profile email'
|
||||
: 'openid profile email offline_access',
|
||||
|
||||
// ^^ Please note that offline_access is not needed for silent refresh
|
||||
// At least when using idsvr, this even prevents silent refresh
|
||||
|
||||
@@ -14,18 +14,23 @@ export class HeaderComponent implements OnInit {
|
||||
|
||||
async login(): Promise<void> {
|
||||
this.oauthService.configure(authConfig);
|
||||
await this.oauthService.loadDiscoveryDocumentAndTryLogin().then((_) => {
|
||||
console.log(
|
||||
'LOGGED=' + (this.oauthService.hasValidIdToken()
|
||||
&& this.oauthService.hasValidAccessToken())
|
||||
);
|
||||
});
|
||||
await this.oauthService.loadDiscoveryDocument();
|
||||
if (
|
||||
!this.oauthService.hasValidIdToken() ||
|
||||
!this.oauthService.hasValidAccessToken()
|
||||
) {
|
||||
this.oauthService.initLoginFlow('some-state');
|
||||
}
|
||||
}
|
||||
|
||||
logout(): void {
|
||||
this.oauthService.revokeTokenAndLogout();
|
||||
}
|
||||
|
||||
get logged(): boolean {
|
||||
return this.oauthService.getIdentityClaims() != null;
|
||||
}
|
||||
|
||||
get name(): any {
|
||||
const claims = this.oauthService.getIdentityClaims();
|
||||
if (!claims) {
|
||||
|
||||
@@ -1,37 +1,6 @@
|
||||
<h3>Mis viajes</h3>
|
||||
<app-list *ngIf="login" [displayedColumns]="displayedColumns" [url]="urlMyTravels"></app-list>
|
||||
<p *ngIf="!login">Logueate para ver tus viajes</p>
|
||||
<app-list *ngIf="logged" [displayedColumns]="displayedColumns" [url]="urlMyTravels"></app-list>
|
||||
<p *ngIf="!logged">Logueate para ver tus viajes</p>
|
||||
|
||||
<h3>Viajes disponibles</h3>
|
||||
<app-list [displayedColumns]="displayedColumns" [url]="urlTravels"></app-list>
|
||||
|
||||
<p>Login={{login}} loginFailed={{loginFailed}}</p>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p><b>access_token_expiration:</b> {{ access_token_expiration }}</p>
|
||||
<p><b>id_token_expiration:</b> {{ id_token_expiration }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p><b>access_token:</b> {{ access_token }}</p>
|
||||
<p><b>id_token:</b> {{ id_token }}</p>
|
||||
<div *ngIf="userProfile">
|
||||
<b>user profile:</b>
|
||||
<pre>{{ userProfile | json }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<h2>Further Actions</h2>
|
||||
<button class="btn btn-default" (click)="refresh()">Refresh</button>
|
||||
|
||||
<button class="btn btn-default" (click)="loadUserProfile()">
|
||||
Load User Profile
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -59,40 +59,7 @@ export class HomeComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
set requestAccessToken(value: boolean) {
|
||||
this.oauthService.requestAccessToken = value;
|
||||
localStorage.setItem('requestAccessToken', '' + value);
|
||||
}
|
||||
|
||||
get requestAccessToken(): boolean {
|
||||
return this.oauthService.requestAccessToken;
|
||||
}
|
||||
|
||||
set useHashLocationStrategy(value: boolean) {
|
||||
const oldValue = localStorage.getItem('useHashLocationStrategy') === 'true';
|
||||
if (value !== oldValue) {
|
||||
localStorage.setItem('useHashLocationStrategy', value ? 'true' : 'false');
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
get useHashLocationStrategy(): boolean {
|
||||
return localStorage.getItem('useHashLocationStrategy') === 'true';
|
||||
}
|
||||
|
||||
get id_token(): string {
|
||||
return this.oauthService.getIdToken();
|
||||
}
|
||||
|
||||
get access_token(): string {
|
||||
return this.oauthService.getAccessToken();
|
||||
}
|
||||
|
||||
get id_token_expiration(): number {
|
||||
return this.oauthService.getIdTokenExpiration();
|
||||
}
|
||||
|
||||
get access_token_expiration(): number {
|
||||
return this.oauthService.getAccessTokenExpiration();
|
||||
get logged(): boolean {
|
||||
return this.oauthService.hasValidIdToken() && this.oauthService.hasValidAccessToken();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ApiService {
|
||||
return this.http
|
||||
.get<ApiResponse<T>>(url, { params })
|
||||
.pipe(
|
||||
retry(3), // retry a failed request up to 3 times
|
||||
retry(0), // retry a failed request up to 3 times
|
||||
catchError(this.handleError) // then handle the error
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user