mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-14 20:27:59 +00:00
@@ -21,44 +21,44 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
email: '',
|
||||
password: ''
|
||||
}
|
||||
email: "",
|
||||
password: "",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleSubmit (e) {
|
||||
e.preventDefault()
|
||||
handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
if (this.password.length > 0) {
|
||||
this.$http
|
||||
.post('http://localhost:3000/login', {
|
||||
.post("http://localhost:3000/login", {
|
||||
email: this.email,
|
||||
password: this.password
|
||||
password: this.password,
|
||||
})
|
||||
.then((response) => {
|
||||
const isAdmin = response.data.user.isAdmin
|
||||
localStorage.setItem('user', JSON.stringify(response.data.user))
|
||||
localStorage.setItem('jwt', response.data.token)
|
||||
let is_admin = response.data.user.is_admin;
|
||||
localStorage.setItem("user", JSON.stringify(response.data.user));
|
||||
localStorage.setItem("jwt", response.data.token);
|
||||
|
||||
if (localStorage.getItem('jwt') != null) {
|
||||
this.$emit('loggedIn')
|
||||
if (localStorage.getItem("jwt") != null) {
|
||||
this.$emit("loggedIn");
|
||||
if (this.$route.params.nextUrl != null) {
|
||||
this.$router.push(this.$route.params.nextUrl)
|
||||
this.$router.push(this.$route.params.nextUrl);
|
||||
} else {
|
||||
if (isAdmin === 1) {
|
||||
this.$router.push('admin')
|
||||
if (is_admin == 1) {
|
||||
this.$router.push("admin");
|
||||
} else {
|
||||
this.$router.push('dashboard')
|
||||
this.$router.push("dashboard");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error.response)
|
||||
})
|
||||
console.error(error.response);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user