Skip to content

Commit

Permalink
Login undefined lowercase fixed (fixes #523) (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
MacNew authored and paulbert committed Mar 20, 2018
1 parent f2a62e1 commit 011e5a7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app/configuration/configuration.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ng-template matStepLabel i18n>Create Admin</ng-template>
<form [formGroup]="loginForm">
<mat-form-field>
<input matInput i18n-placeholder placeholder="Username" formControlName="username" required>
<input matInput i18n-placeholder placeholder="Username" formControlName="username" required planetLowercase>
<mat-error><planet-form-error-messages [control]="loginForm.controls.username"></planet-form-error-messages></mat-error>
</mat-form-field>
<mat-form-field>
Expand Down
4 changes: 2 additions & 2 deletions src/app/login/login-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ export class LoginFormComponent {
}

login({ name, password }: {name: string, password: string}, isCreate: boolean) {
this.couchService.post('_session', { 'name': name.toLowerCase(), 'password': password }, { withCredentials: true })
this.couchService.post('_session', { 'name': name, 'password': password }, { withCredentials: true })
.pipe(switchMap((data) => {
// Post new session info to login_activity
return this.userService.newSessionLog();
})).subscribe((res) => {
if (isCreate) {
this.router.navigate( [ 'users/update/' + name.toLowerCase() ]);
this.router.navigate( [ 'users/update/' + name ]);
} else {
this.reRoute();
}
Expand Down
12 changes: 6 additions & 6 deletions src/app/shared/lowercase.directive.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Directive, Input, HostBinding, HostListener } from '@angular/core';
import { Directive, HostListener } from '@angular/core';
import { NgControl } from '@angular/forms';

// For use on input elements within Reactive forms to force text lowercase
@Directive({
selector: '[planetLowercase]'
})
export class LowercaseDirective {
@Input() lowercase: string;
@HostBinding('value') value = '';

constructor() {}
constructor(private controlRef: NgControl) {}

@HostListener('keyup') onMouseEnter() {
this.value = this.lowercase.toLowerCase();
@HostListener('input', [ '$event' ]) onInput($event) {
this.controlRef.control.setValue($event.target.value.toLowerCase());
}
}

0 comments on commit 011e5a7

Please sign in to comment.