mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-18 22:18:04 +00:00
@@ -7,12 +7,12 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
msg: 'The superheros'
|
||||
}
|
||||
}
|
||||
}
|
||||
msg: "The superheros",
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
h1,
|
||||
@@ -30,4 +30,4 @@ li {
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
msg: 'Hello World!'
|
||||
}
|
||||
}
|
||||
}
|
||||
msg: "Hello World!",
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<label for="password-confirm">Is this an administrator account?</label>
|
||||
<div>
|
||||
<select v-model="isAdmin">
|
||||
<select v-model="is_admin">
|
||||
<option value="1">Yes</option>
|
||||
<option value="0">No</option>
|
||||
</select>
|
||||
@@ -44,58 +44,57 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ['nextUrl'],
|
||||
data () {
|
||||
props: ["nextUrl"],
|
||||
data() {
|
||||
return {
|
||||
name: '',
|
||||
email: '',
|
||||
password: '',
|
||||
password_confirmation: '',
|
||||
isAdmin: null
|
||||
}
|
||||
name: "",
|
||||
email: "",
|
||||
password: "",
|
||||
password_confirmation: "",
|
||||
is_admin: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleSubmit (e) {
|
||||
e.preventDefault()
|
||||
handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (
|
||||
this.password === this.password_confirmation &&
|
||||
this.password.length > 0
|
||||
) {
|
||||
let url = 'http://localhost:3000/register'
|
||||
if (this.isAdmin != null || this.isAdmin === 1) {
|
||||
url = 'http://localhost:3000/register-admin'
|
||||
}
|
||||
let url = "http://localhost:3000/register";
|
||||
if (this.is_admin != null || this.is_admin == 1)
|
||||
url = "http://localhost:3000/register-admin";
|
||||
this.$http
|
||||
.post(url, {
|
||||
name: this.name,
|
||||
email: this.email,
|
||||
password: this.password,
|
||||
isAdmin: this.isAdmin
|
||||
is_admin: this.is_admin,
|
||||
})
|
||||
.then((response) => {
|
||||
localStorage.setItem('user', JSON.stringify(response.data.user))
|
||||
localStorage.setItem('jwt', response.data.token)
|
||||
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 {
|
||||
this.$router.push('/')
|
||||
this.$router.push("/");
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
})
|
||||
console.error(error);
|
||||
});
|
||||
} else {
|
||||
this.password = ''
|
||||
this.passwordConfirm = ''
|
||||
this.password = "";
|
||||
this.passwordConfirm = "";
|
||||
|
||||
return alert('Passwords do not match')
|
||||
return alert("Passwords do not match");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
msg: 'The commoners'
|
||||
}
|
||||
}
|
||||
}
|
||||
msg: "The commoners",
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
@@ -32,4 +32,4 @@ li {
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user