Configurar a possibilidade de inativar autenticação por user+password
Some checks failed
Release / release (push) Failing after 10m3s
Some checks failed
Release / release (push) Failing after 10m3s
fixes #13
This commit is contained in:
parent
93193c6165
commit
c3eb88972c
7 changed files with 89 additions and 34 deletions
|
@ -3,7 +3,7 @@ import { Router } from '@angular/router';
|
|||
import { HttpClient } from '@angular/common/http';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Observable, ReplaySubject, of } from 'rxjs';
|
||||
import { shareReplay, tap, catchError } from 'rxjs/operators';
|
||||
import { shareReplay, tap, catchError, map } from 'rxjs/operators';
|
||||
|
||||
import { StateStorageService } from 'app/core/auth/state-storage.service';
|
||||
import { Account } from 'app/core/auth/account.model';
|
||||
|
@ -95,6 +95,14 @@ export class AccountService {
|
|||
return this.http.get(this.applicationConfigService.getEndpointFor('api/account/saml2-endpoint'), { responseType: 'text' as 'text' });
|
||||
}
|
||||
|
||||
hasBasicAuth(): Observable<boolean> {
|
||||
return this.http.get(
|
||||
this.applicationConfigService.getEndpointFor('api/account/has-basic-auth'), { responseType: 'text' as 'text' }
|
||||
).pipe(
|
||||
map(response => response === 'true')
|
||||
);;
|
||||
}
|
||||
|
||||
private fetch(): Observable<Account> {
|
||||
return this.http.get<Account>(this.applicationConfigService.getEndpointFor('api/account'));
|
||||
}
|
||||
|
|
|
@ -12,33 +12,35 @@
|
|||
</div>
|
||||
}
|
||||
<form class="form" (ngSubmit)="login()" [formGroup]="loginForm">
|
||||
<div class="form-group">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control form-control-lg"
|
||||
name="username"
|
||||
id="username"
|
||||
placeholder="{{ 'global.form.username.placeholder' | translate }}"
|
||||
formControlName="username"
|
||||
#username
|
||||
data-cy="username"
|
||||
/>
|
||||
<div *ngIf="hasBasicAuth">
|
||||
<div class="form-group">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control form-control-lg"
|
||||
name="username"
|
||||
id="username"
|
||||
placeholder="{{ 'global.form.username.placeholder' | translate }}"
|
||||
formControlName="username"
|
||||
#username
|
||||
data-cy="username"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<input
|
||||
type="password"
|
||||
class="form-control form-control-lg"
|
||||
name="password"
|
||||
id="password"
|
||||
placeholder="{{ 'login.form.password.placeholder' | translate }}"
|
||||
formControlName="password"
|
||||
data-cy="password"
|
||||
/>
|
||||
</div>
|
||||
<p class="text-right"><a routerLink="/account/reset/request" data-cy="forgetYourPasswordSelector" jhiTranslate="login.password.forgot">Esqueci-me da palavra passe</a></p>
|
||||
<button type="submit" class="btn btn-primary btn-block btn-lg mb-3" data-cy="submit" jhiTranslate="login.form.button">Entrar</button>
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<input
|
||||
type="password"
|
||||
class="form-control form-control-lg"
|
||||
name="password"
|
||||
id="password"
|
||||
placeholder="{{ 'login.form.password.placeholder' | translate }}"
|
||||
formControlName="password"
|
||||
data-cy="password"
|
||||
/>
|
||||
</div>
|
||||
<p class="text-right"><a routerLink="/account/reset/request" data-cy="forgetYourPasswordSelector" jhiTranslate="login.password.forgot">Esqueci-me da palavra passe</a></p>
|
||||
<button type="submit" class="btn btn-primary btn-block btn-lg mb-3" data-cy="submit" jhiTranslate="login.form.button">Entrar</button>
|
||||
<p *ngIf="hasBasicAuth && saml2Endpoint">ou</p>
|
||||
<div *ngIf="saml2Endpoint">
|
||||
<p>ou</p>
|
||||
<button (click)="samlLogin()" class="btn btn-default btn-block btn-lg mb-5">Login NOVA</button>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -17,6 +17,7 @@ export default class LoginComponent implements OnInit, AfterViewInit {
|
|||
username = viewChild.required<ElementRef>('username');
|
||||
saml2Endpoint : string | null = null;
|
||||
authenticationError = signal(false);
|
||||
hasBasicAuth: boolean = false;
|
||||
|
||||
loginForm = new FormGroup({
|
||||
username: new FormControl('', { nonNullable: true, validators: [Validators.required] }),
|
||||
|
@ -44,6 +45,15 @@ export default class LoginComponent implements OnInit, AfterViewInit {
|
|||
console.error('Failed to fetch SAML2 endpoint', err);
|
||||
}
|
||||
});
|
||||
|
||||
this.accountService.hasBasicAuth().subscribe({
|
||||
next: (response: boolean) => {
|
||||
this.hasBasicAuth = response;
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Failed to fetch hasBasicAuth', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue