KEYCLOAK-7047: Fix RegistrationEmailAsUsername and EditUserNameAllowed (#5122)
on personal info page.
This commit is contained in:
parent
b3b81d6a76
commit
701c318b60
4 changed files with 15 additions and 6 deletions
|
@ -89,6 +89,8 @@ public class AccountConsole {
|
|||
map.put("authUrl", session.getContext().getContextPath());
|
||||
map.put("baseUrl", session.getContext().getContextPath() + "/realms/" + realm.getName() + "/account");
|
||||
map.put("realm", realm.getName());
|
||||
map.put("isRegistrationEmailAsUsername", realm.isRegistrationEmailAsUsername());
|
||||
map.put("isEditUserNameAllowed", realm.isEditUsernameAllowed());
|
||||
map.put("resourceUrl", Urls.themeRoot(baseUri).getPath() + "/account/" + theme.getName());
|
||||
map.put("resourceVersion", Version.RESOURCES_VERSION);
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
var baseUrl = '${baseUrl}';
|
||||
var realm = '${realm}';
|
||||
var resourceUrl = '${resourceUrl}';
|
||||
var isRegistrationEmailAsUsername = ${isRegistrationEmailAsUsername?c};
|
||||
var isEditUserNameAllowed = ${isEditUserNameAllowed?c};
|
||||
|
||||
<#if referrer??>
|
||||
var referrer = '${referrer}';
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
|
||||
<form #formGroup="ngForm" (ngSubmit)="saveAccount()" class="form-horizontal">
|
||||
|
||||
<div class="form-group ">
|
||||
<div *ngIf="!isRegistrationEmailAsUsername" class="form-group ">
|
||||
<div class="col-sm-2 col-md-2">
|
||||
<label for="username" class="control-label">{{'username' | translate}}</label>
|
||||
<label for="username" class="control-label">{{'username' | translate}}</label><span *ngIf="isEditUserNameAllowed" class="required">*</span>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-10 col-md-10">
|
||||
<input type="text" class="form-control" id="username" name="username" disabled value="{{username}}" >
|
||||
<input *ngIf="isEditUserNameAllowed" type="text" class="form-control" required ngModel id="username" name="username" value="{{username}}" >
|
||||
<span *ngIf="!isEditUserNameAllowed">{{ username }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -20,18 +20,22 @@ import {FormGroup} from '@angular/forms';
|
|||
|
||||
import {AccountServiceClient} from '../../account-service/account.service';
|
||||
|
||||
declare const isRegistrationEmailAsUsername: boolean;
|
||||
declare const isEditUserNameAllowed: boolean;
|
||||
|
||||
@Component({
|
||||
selector: 'app-account-page',
|
||||
templateUrl: './account-page.component.html',
|
||||
styleUrls: ['./account-page.component.css']
|
||||
})
|
||||
export class AccountPageComponent implements OnInit {
|
||||
private isRegistrationEmailAsUsername: boolean = isRegistrationEmailAsUsername;
|
||||
private isEditUserNameAllowed: boolean = isEditUserNameAllowed;
|
||||
|
||||
@ViewChild('formGroup') private formGroup: FormGroup;
|
||||
|
||||
// using ordinary variable here
|
||||
// disabled fields not working properly with FormGroup
|
||||
// FormGroup.getRawValue() causes page refresh. Not sure why?
|
||||
// using ordinary variable here for case where username
|
||||
// is not editable and not controlled by formGroup
|
||||
private username: string;
|
||||
|
||||
constructor(private accountSvc: AccountServiceClient ) {
|
||||
|
|
Loading…
Reference in a new issue