Commit 2a857f54 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh
parents 72a3270f 45cd82b6
......@@ -111,38 +111,30 @@ export default {
},
async login () {
try {
const resp = await fetch('http://127.0.0.1:8000/api/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stringify({
const resp = await this.$axios.post('/login',
{
email: this.email,
password: this.password,
status: this.status
})
}).then((response) => {
return response.json()
})
console.log(resp.status)
localStorage.setItem('token', resp.data.bearer_token)
this.$auth.$storage.setUniversal('token', resp.data.bearer_token)
this.$auth.$storage.setUniversal('userName', resp.data.name)
this.$auth.$storage.setUniversal('loggedIn', 'true')
if (resp.status == 'success') {
this.$toast.success('Successfully authenticated', {
duration: 2000
status: this.status,
})
this.$router.push('home')
localStorage.setItem("token", resp.data.data.bearer_token)
this.$auth.$storage.setUniversal("token", resp.data.data.bearer_token)
this.$auth.$storage.setUniversal("userName", resp.data.data.name)
this.$auth.$storage.setUniversal("loggedIn", "true")
if (resp.status == "200") {
this.$toast.success("Successfully authenticated", {
duration: 2000,
});
this.$router.push("home");
}
} catch (e) {
this.$toast.error('Username or Password not valid', {
duration: 2000
})
this.$router.push('/login')
this.$toast.error("Username or Password not valid", {
duration: 2000,
});
this.$router.push("/login");
}
}
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment