Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix registration not displaying and switch error messages to uswds #6

Merged
merged 1 commit into from Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/src/app/auth/auth.component.ts
Expand Up @@ -8,7 +8,7 @@ import { Router } from '@angular/router';
})
export class AuthComponent implements OnInit {

@Input() authMode: 'Login' | 'Register' = 'Login';
@Input() authMode: 'login' | 'register' = 'login';

constructor( private router: Router ) { }

Expand All @@ -33,11 +33,11 @@ export class AuthComponent implements OnInit {
}

isLoginMode() {
return this.authMode === 'Login';
return this.authMode === 'login';
}

isRegisterMode() {
return this.authMode === 'Register';
return this.authMode === 'register';
}


Expand Down
28 changes: 17 additions & 11 deletions frontend/src/app/register-form/register-form.component.html
Expand Up @@ -6,26 +6,32 @@
name='email'
[(ngModel)]="signUpUser.email"
class="validate" />

<!-- Name field needs wired up (added to db?)-->
<label for="email">Name</label>
<input id="name"
type="text"
name='name' />

<label for="password_create">Password</label>
<input id="password_create"
type="password"
required
name='password'
[(ngModel)]="signUpUser.password"
class="validate" />
<label for="password_confirmation">Password confirmation</label>
<input id="password_confirmation"
type="password"
required
name='password_confirmation'
[(ngModel)]="signUpUser.passwordConfirmation"
class="validate" />

<div class="usa-alert usa-alert-error" *ngIf="signUpUser.password != signUpUser.passwordConfirmation">
<div class="usa-alert-body">
<p class="usa-alert-text">Passwords must match</p>
</div>
<div [ngClass]="{'usa-input-error' : signUpUser.password != signUpUser.passwordConfirmation}">
<label for="password_confirmation">Password confirmation</label>
<input id="password_confirmation"
type="password"
required
name='password_confirmation'
[(ngModel)]="signUpUser.passwordConfirmation"
class="validate" />
<span class="usa-input-error-message" *ngIf="signUpUser.password != signUpUser.passwordConfirmation" role="alert">Passwords must match</span>
</div>

<input type="submit"
[disabled]="!(f.valid) || !(signUpUser.password == signUpUser.passwordConfirmation)"
value="Sign up" />
Expand Down
17 changes: 6 additions & 11 deletions frontend/src/app/register-form/register-form.component.ts
@@ -1,5 +1,4 @@

import {Component, OnInit, EventEmitter, Output} from '@angular/core';
import {Component, OnInit, Output, EventEmitter} from '@angular/core';
import {AuthService} from '../services/auth.service';

@Component({
Expand All @@ -17,28 +16,24 @@ export class RegisterFormComponent implements OnInit {

@Output() onFormResult = new EventEmitter<any>();

constructor(public authService: AuthService) { }
constructor(public authService: AuthService) {}

ngOnInit() {}


onSignUpSubmit() {

this.authService.registerUser(this.signUpUser).subscribe(

(res) => {

res => {
if (res.status === 200) {
this.onFormResult.emit({signedUp: true, res});
}

},

(err) => {
console.log(err.json());
err => {
console.log('err:', err);
this.onFormResult.emit({signedUp: false, err});
}
);

}

}
2 changes: 1 addition & 1 deletion frontend/src/app/toolbar/toolbar.component.html
Expand Up @@ -27,7 +27,7 @@
</nav>

<div class="a2-profile center-align" *ngIf="(authService.userSignedIn$ | async)">
<img src="./../../../assets/images/avatar.png" class="circle img-50" alt="John Smith">
<img *ngIf="authTokenService.currentUserData" src="./../../../assets/images/avatar.png" class="circle img-50" alt="John Smith">
<p *ngIf="authTokenService.currentUserData">
<b>{{authTokenService.currentUserData.name}} Bob Smith</b>
<br/><small>{{authTokenService.currentUserData.email}}</small>
Expand Down