Skip to content

Commit 891ad1b

Browse files
sign up refactoring done
1 parent bca6d04 commit 891ad1b

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/components/sing-up/sign-up.component.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@ class SignUp extends React.Component {
2222
const { displayName, email, password, confirmPassword } = this.state;
2323
const user = {displayName,email,password,confirmPassword};
2424
const {signUpStart} = this.props;
25-
signUpStart(user);
26-
27-
/*
2825
if (password !== confirmPassword) {
2926
alert("passwords don't match");
3027
return;
3128
}
29+
signUpStart(user);
30+
31+
/*
3232
3333
try {
3434
const { user } = await auth.createUserWithEmailAndPassword(
3535
email,
3636
password
3737
);
38-
createUserProfileDocument(user, { displayName });
3938
//vuelvo a los valores por defecto, no estoy muy seguro para que es esto...
4039
this.setState({
4140
displayName: "",

src/redux/user/user.sagas.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,16 @@ export function* signInWithEmail({payload : {email,password}}){
6565

6666
export function* signUp({payload :{ displayName, email, password, confirmPassword }}){
6767
try{
68-
69-
if(password !== confirmPassword){
70-
alert("Passwords doesn't match");
71-
yield(put(signUpFailure("Passwords doesn't match.")))
72-
}
73-
else {
74-
75-
const { user } = auth.createUserWithEmailAndPassword(
68+
69+
const {user} = yield auth.createUserWithEmailAndPassword(
7670
email,
7771
password
7872
);
79-
yield put(signUpSuccess(user));
73+
const userToIns = yield createUserProfileDocument(user, { displayName });
74+
yield put(signInSuccess(userToIns));
8075
}
8176

82-
}
77+
8378
catch(error){
8479
yield(put(signUpFailure(error)))
8580

0 commit comments

Comments
 (0)