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