add the signup process
This commit is contained in:
parent
87c386bbd4
commit
ba84e606c5
|
@ -57,6 +57,15 @@ export default {
|
|||
this.formIsValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.mode === 'login') {
|
||||
//
|
||||
} else {
|
||||
this.$store.dispatch('signup', {
|
||||
email: this.email,
|
||||
password: this.password
|
||||
});
|
||||
}
|
||||
},
|
||||
switchAuthMode() {
|
||||
if (this.mode === 'login') {
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
//import getAPI from '../../../scripts/axios-api';
|
||||
import getAuth from '../../../scripts/axios-auth';
|
||||
|
||||
export default {};
|
||||
export default {
|
||||
login() {},
|
||||
async signup(context, payload) {
|
||||
try {
|
||||
const response = await getAuth.post('accounts:signUp', {
|
||||
email: payload.email,
|
||||
password: payload.password,
|
||||
returnSecureToken: true
|
||||
});
|
||||
const responseData = response.data;
|
||||
console.log(responseData);
|
||||
context.commit('setUser', {
|
||||
token: responseData.idToken,
|
||||
userId: responseData.localId,
|
||||
tokenExpiration: responseData.expiresIn
|
||||
});
|
||||
} catch (err) {
|
||||
const error = new Error(err.message);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,7 +5,9 @@ import mutations from './mutations';
|
|||
export default {
|
||||
state() {
|
||||
return {
|
||||
userId: 'c3'
|
||||
userId: null,
|
||||
token: null,
|
||||
tokenExpiration: null
|
||||
};
|
||||
},
|
||||
actions,
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
export default {};
|
||||
export default {
|
||||
setUser(state, payload) {
|
||||
state.token = payload.token;
|
||||
state.userId = payload.userId;
|
||||
state.tokenExpiration = payload.tokenExpiration;
|
||||
}
|
||||
};
|
||||
|
|
Reference in New Issue