Skip to content

Commit

Permalink
Fixed user authentication/registration accessibility issue
Browse files Browse the repository at this point in the history
- Added the correct autocomplete value
- Removed dangling labels, because aria labels already describe those input fields & we can't use ids in this component because otherwise there are duplicate ids on the /login page
  • Loading branch information
alexandrevryghem committed Dec 26, 2023
1 parent d7017ca commit 60cba0d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="container" *ngIf="(registration$ |async)">
<h3 class="mb-4">{{'forgot-password.form.head' | translate}}</h3>
<h1 class="mb-4">{{'forgot-password.form.head' | translate}}</h1>
<div class="card mb-4">
<div class="card-header">{{'forgot-password.form.identification.header' | translate}}</div>
<div class="card-body">
<div class="row">
<div class="col-12">
<label class="font-weight-bold"
for="email">{{'forgot-password.form.identification.email' | translate}}</label>
<span id="email">{{(registration$ |async).email}}</span></div>
<span class="font-weight-bold">{{'forgot-password.form.identification.email' | translate}} </span>
<span [attr.data-test]="'email' | dsBrowserOnly">{{(registration$ |async).email}}</span>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
createSuccessfulRemoteDataObject$
} from '../../shared/remote-data.utils';
import { CoreState } from '../../core/core-state.model';
import { BrowserOnlyPipe } from '../../shared/utils/browser-only.pipe';

describe('ForgotPasswordFormComponent', () => {
let comp: ForgotPasswordFormComponent;
Expand Down Expand Up @@ -54,7 +55,10 @@ describe('ForgotPasswordFormComponent', () => {

TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), ReactiveFormsModule],
declarations: [ForgotPasswordFormComponent],
declarations: [
BrowserOnlyPipe,
ForgotPasswordFormComponent,
],
providers: [
{provide: Router, useValue: router},
{provide: ActivatedRoute, useValue: route},
Expand All @@ -75,7 +79,7 @@ describe('ForgotPasswordFormComponent', () => {

describe('init', () => {
it('should initialise mail address', () => {
const elem = fixture.debugElement.queryAll(By.css('span#email'))[0].nativeElement;
const elem = fixture.debugElement.queryAll(By.css('span[data-test="email"]'))[0].nativeElement;
expect(elem.innerHTML).toContain('[email protected]');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export class ProfilePageMetadataFormComponent implements OnInit {
new DynamicInputModel({
id: 'email',
name: 'email',
readOnly: true
readOnly: true,
disabled: true,
}),
new DynamicInputModel({
id: 'firstname',
Expand All @@ -55,6 +56,7 @@ export class ProfilePageMetadataFormComponent implements OnInit {
errorMessages: {
required: 'This field is required'
},
autoComplete: 'given-name',
}),
new DynamicInputModel({
id: 'lastname',
Expand All @@ -66,10 +68,12 @@ export class ProfilePageMetadataFormComponent implements OnInit {
errorMessages: {
required: 'This field is required'
},
autoComplete: 'family-name',
}),
new DynamicInputModel({
id: 'phone',
name: 'eperson.phone'
name: 'eperson.phone',
autoComplete: 'tel',
}),
new DynamicSelectModel<string>({
id: 'language',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ export class ProfilePageSecurityFormComponent implements OnInit {
new DynamicInputModel({
id: 'password',
name: 'password',
inputType: 'password'
inputType: 'password',
autoComplete: 'new-password',
}),
new DynamicInputModel({
id: 'passwordrepeat',
name: 'passwordrepeat',
inputType: 'password'
inputType: 'password',
autoComplete: 'new-password',
})
];

Expand Down Expand Up @@ -79,7 +81,8 @@ export class ProfilePageSecurityFormComponent implements OnInit {
id: 'current-password',
name: 'current-password',
inputType: 'password',
required: true
required: true,
autoComplete: 'current-password',
}));
}
if (this.passwordCanBeEmpty) {
Expand Down
3 changes: 1 addition & 2 deletions src/app/profile-page/profile-page.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<ng-container *ngVar="(user$ | async) as user">
<div class="container" *ngIf="user">
<h1>{{'profile.title' | translate}}</h1>
<ng-container *ngIf="isResearcherProfileEnabled() | async">
<h2 class="mb-4">{{'profile.head' | translate}}</h2>
<ng-container>
<div class="card mb-4">
<div class="card-header">{{'profile.card.researcher' | translate}}</div>
<div class="card-body">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<form class="form-login"
(ngSubmit)="submit()"
[formGroup]="form" novalidate>
<label class="sr-only">{{"login.form.email" | translate}}</label>
<input [attr.aria-label]="'login.form.email' |translate"
autocomplete="off"
autocomplete="username"
autofocus
class="form-control form-control-lg position-relative"
formControlName="email"
placeholder="{{'login.form.email' | translate}}"
required
type="email"
[attr.data-test]="'email' | dsBrowserOnly">
<label class="sr-only">{{"login.form.password" | translate}}</label>
<input [attr.aria-label]="'login.form.password' |translate"
autocomplete="off"
autocomplete="current-password"
class="form-control form-control-lg position-relative mb-3"
placeholder="{{'login.form.password' | translate}}"
formControlName="password"
Expand Down
4 changes: 1 addition & 3 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@

"forgot-password.form.label.passwordrepeat": "Retype to confirm",

"forgot-password.form.error.empty-password": "Please enter a password in the box below.",
"forgot-password.form.error.empty-password": "Please enter a password in the boxes above.",

"forgot-password.form.error.matching-passwords": "The passwords do not match.",

Expand Down Expand Up @@ -3486,8 +3486,6 @@

"profile.special.groups.head": "Authorization special groups you belong to",

"profile.head": "Update Profile",

"profile.metadata.form.error.firstname.required": "First Name is required",

"profile.metadata.form.error.lastname.required": "Last Name is required",
Expand Down

0 comments on commit 60cba0d

Please sign in to comment.