Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- userLogin({ commit }, { email, password }) {
- firebase
- .auth()
- .signInWithEmailAndPassword(email, password)
- .then(user => {
- commit("setUser", user);
- commit("setIsAuthenticated", true);
- console.log("User: " + user.user.uid + "found")
- router.push("/dashboard");
- })
- .catch((error) => {
- commit("setUser", null);
- commit("setIsAuthenticated", false);
- console.log("Login Error: " + error.message);
- router.go({name: "signin", force: true, query: {errorMessage: error.message, signinError: true}});
- });
- },
- data() {
- return {
- email: "",
- password: "",
- performingRequest: false,
- signinError: false,
- signupSuccessful: false,
- errorMessage: "",
- successMessage: ""
- };
- },
- created() {
- if(this.$route.query.signinError) {
- this.signinError = this.$route.query.signinError;
- this.errorMessage = this.$route.query.errorMessage;
- }
- },
- methods: {
- validateStep(scope) {
- this.$validator.validateAll(scope).then(result => {
- if (result) {
- this.performingRequest = true
- this.$store.dispatch("userLogin", {
- email: this.email,
- password: this.password
- })
- }
- });
- }
- }
- <v-alert :value="signinError" type="error" >
- {{errorMessage}}
- </v-alert>
- <v-alert :value="signupSuccessful" type="success" >
- {{successMessage}}
- </v-alert>
Add Comment
Please, Sign In to add comment