Full-Stack Web Development with Vue.js and Node

(singke) #1

Building OAuth Strategies with passport.js Chapter 7


'E-mail must be valid'
],
passwordRules: [
(v) => !!v || 'Password is required',
]
}),
methods: {
async submit () {
if (this.$refs.form.validate()) {
return axios({
method: 'post',
data: {
email: this.email,
password: this.password
},
url: '/users/login',
headers: {
'Content-Type': 'application/json'
}
})
.then((response) => {
localStorage.setItem('jwtToken', response.data.token)
this.$swal("Good job!", "You are ready to start!",
"success");
bus.$emit("refreshUser");
this.$router.push({ name: 'Home' });
})
.catch((error) => {
const message = error.response.data.message;
this.$swal("Oh oo!", `${message}`, "error")
});
}
},
clear () {
this.$refs.form.reset()
}
}
}
</script>
Free download pdf