signup signin code modify
This commit is contained in:
parent
ce0b285ab2
commit
b061609317
|
@ -6,7 +6,13 @@
|
|||
</div>
|
||||
<div class="ui-g-12">
|
||||
<span class="md-inputfield">
|
||||
<input id="email" type="email" pInputText class="input ng-dirty ng-invalid" placeholder="Email" formControlName="email" required>
|
||||
<input type="email"
|
||||
id="email"
|
||||
pInputText
|
||||
class="input ng-dirty ng-invalid"
|
||||
placeholder="Email"
|
||||
formControlName="email" required
|
||||
value="geekhot@hotmail.co.kr" />
|
||||
<div *ngIf="email.touched && !email.valid" class="ui-message ui-messages-error ui-corner-all">
|
||||
Invalid email
|
||||
</div>
|
||||
|
@ -14,7 +20,8 @@
|
|||
</div>
|
||||
<div class="ui-g-12">
|
||||
<span class="md-inputfield">
|
||||
<input id="password" type="password" pInputText class="input ng-dirty ng-invalid" placeholder="Password" formControlName="password"
|
||||
<input type="password"
|
||||
id="password" pInputText class="input ng-dirty ng-invalid" placeholder="Password" formControlName="password"
|
||||
required>
|
||||
<div *ngIf="password.touched && !password.valid" class="ui-message ui-messages-error ui-corner-all">
|
||||
Invalid password
|
||||
|
|
|
@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
|
|||
import { Router } from '@angular/router';
|
||||
import { FormGroup, FormBuilder, Validators, AbstractControl, FormControl } from '@angular/forms';
|
||||
import { Member } from '../../model';
|
||||
import * as AuthStore from '../../store/signup';
|
||||
import {Store} from '@ngrx/store';
|
||||
|
||||
@Component({
|
||||
selector: 'of-member-signup',
|
||||
|
@ -20,7 +22,8 @@ export class SignupComponent implements OnInit {
|
|||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private formBuilder: FormBuilder
|
||||
private formBuilder: FormBuilder,
|
||||
private store: Store<AuthStore.State>,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -29,33 +32,45 @@ export class SignupComponent implements OnInit {
|
|||
|
||||
initForm() {
|
||||
this.signupForm = this.formBuilder.group({
|
||||
'email': ['', [
|
||||
'email': [
|
||||
'geekhot@hotmail.co.kr',
|
||||
[
|
||||
Validators.required,
|
||||
Validators.email
|
||||
]
|
||||
],
|
||||
'password': ['', [
|
||||
'password': [
|
||||
'!@#$Qwer1234',
|
||||
[
|
||||
Validators.required,
|
||||
Validators.pattern('^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$'),
|
||||
Validators.pattern('^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{6,}$'),
|
||||
Validators.minLength(6),
|
||||
Validators.maxLength(25),
|
||||
]
|
||||
],
|
||||
'pwConfirm': ['', [
|
||||
'pwConfirm': [
|
||||
'!@#$Qwer1234',
|
||||
[
|
||||
Validators.compose([
|
||||
Validators.required, this.pwMatchValidator
|
||||
])
|
||||
]
|
||||
],
|
||||
'name': ['', [
|
||||
'name': [
|
||||
'Park',
|
||||
[
|
||||
Validators.required
|
||||
]
|
||||
],
|
||||
'phone': ['', [
|
||||
'phone': [
|
||||
'010-3040-0303',
|
||||
[
|
||||
Validators.required
|
||||
]
|
||||
],
|
||||
'company': ['', [
|
||||
'company': [
|
||||
'atgame',
|
||||
[
|
||||
Validators.required
|
||||
]
|
||||
],
|
||||
|
@ -79,14 +94,16 @@ export class SignupComponent implements OnInit {
|
|||
}
|
||||
|
||||
signup() {
|
||||
const signinValue = Object.assign({}, this.signupForm.value);
|
||||
const signupValue = Object.assign({}, this.signupForm.value);
|
||||
const password = signupValue.password;
|
||||
const member: Member = {
|
||||
email: signinValue.email,
|
||||
password: signinValue.password,
|
||||
name: signinValue.name,
|
||||
phone: signinValue.phone,
|
||||
companyName: signinValue.company,
|
||||
email: signupValue.email,
|
||||
password: signupValue.password,
|
||||
name: signupValue.name,
|
||||
phone: signupValue.phone,
|
||||
companyName: signupValue.company,
|
||||
};
|
||||
this.store.dispatch(new AuthStore.Signup({member, password}));
|
||||
console.log(member);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,10 +34,11 @@ export class MemberService {
|
|||
});
|
||||
}
|
||||
|
||||
public signup(member: Member): Observable<Member> {
|
||||
public signup(member: Member, password: string): Observable<Member> {
|
||||
return this.restService.request<Member>('post', '/account/signup', {
|
||||
body: {
|
||||
member: member,
|
||||
password: password,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ export enum ActionType {
|
|||
export class Signup implements Action {
|
||||
readonly type = ActionType.Signup;
|
||||
|
||||
constructor(public payload: Member) {}
|
||||
constructor(public payload: {member: Member, password: string}) {}
|
||||
}
|
||||
|
||||
export class SignupSuccess implements Action {
|
||||
|
|
|
@ -36,9 +36,9 @@ export class Effects {
|
|||
signup$: Observable<Action> = this.actions$
|
||||
.ofType(ActionType.Signup)
|
||||
.map((action: Signup) => action.payload)
|
||||
.exhaustMap(member =>
|
||||
.exhaustMap(payload =>
|
||||
this.memberService
|
||||
.signup(member)
|
||||
.signup(payload.member, payload.password)
|
||||
.map(_member => new SignupSuccess(_member))
|
||||
.catch(error => of(new SignupFailure(error)))
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user