login and register

This commit is contained in:
jslightham
2020-03-29 17:06:10 -04:00
parent a35b789e16
commit 80539432e7
11 changed files with 134 additions and 181 deletions

View File

@@ -1,24 +1,26 @@
<template>
<form @submit.prevent="add">
<div class="login">
<h1 class="title">Login</h1>
<div class="field">
<label class="label">Username</label>
<div class="control">
<input class="input" type="text" placeholder="e.g Alex Smith" name="username">
<input type="text" class="form-control" v-model="post.user">
</div>
</div>
<div class="field">
<label class="label">Password</label>
<div class="control">
<input class="input" type="password" placeholder="e.g. alexsmith@gmail.com" name="password">
<input type="password" class="form-control" v-model="post.pass">
</div>
</div>
<div class="login-button">
<div class="control">
<button @click="add()">Click Me</button>
<button>Click Me</button>
</div>
</div>
</div>
</form>
</template>
<style>
@@ -31,22 +33,26 @@
<script>
export default {
methods: {
data() {
data() {
return {
post: {}
}
},
methods: {
add(){
let uri = 'http://localhost:4000/login/post';
this.axios.post(uri, this.post).then(() => {
this.$router.push({username: 'username'});
this.$router.push({password: 'password'});
let uri = 'http://65.92.152.100:4000/login/post';
this.axios.post(uri, this.post).then(res => {
if(!res.data){
alert("Incorrect Username/Password");
}else{
this.$router.push({name: 'account'});
console.log(res.data);
alert("Username: " + res.data.user);
alert("Password: " + res.data.pass);
document.cookie = "user="+res.data.user;
}
});
}
}
}
}
</script>