Skip to content

Instantly share code, notes, and snippets.

@sirramongabriel
Created February 26, 2019 18:01
Show Gist options
  • Save sirramongabriel/799103f8912fddb1ffbae440a1cbf1fa to your computer and use it in GitHub Desktop.
Save sirramongabriel/799103f8912fddb1ffbae440a1cbf1fa to your computer and use it in GitHub Desktop.
The component
<template>
<div class="login">
<form action="/create" method="post" v-on:submit.prevent="login">
<div class="d-flex align-items-center justify-content-center bg-br-primary ht-100v">
<div class="login-wrapper wd-300 wd-xs-400 pd-25 pd-xs-40 bg-white rounded shadow-base">
<div class="signin-logo tx-center tx-28 tx-bold tx-inverse"><span class="tx-normal">Welcome back!</span></div>
<div class="tx-center mg-b-40">Record-Keeping For Perfectionists &amp; {{ store.entities.data.test_message }}</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter your email" v-model="store.user_logins.email" autofocus>
</div><!-- form-group -->
<div class="form-group">
<input type="password" class="form-control" placeholder="Enter your password" v-model="store.user_logins.password">
</div><!-- form-group -->
<button type="submit" v-on:click="toSplash" class="btn btn-sm btn-danger btn-block">Cancel</button>
<button type="submit" v-on:click="login" class="btn btn-sm btn-primary btn-block">Login</button>
<div class="mg-t-40 tx-center">Not a member? <a href="" class="tx-info">Join us!</a></div>
</div><!-- login-wrapper -->
</div><!-- d-flex -->
</form>
</div>
<!-- TypeError: Cannot read property '$store' of null -->
</template>
<script>
import axios from "axios";
import UserLogin from "../models/sessions/UserLogin";
// const store = UserLogin.store();
const userLogin = new UserLogin();
const store = userLogin.$store();
export default {
name: "login",
computed: {
},
methods: {
login: (email, password) => {
this.$store.dispatch('entities/user_logins/create', { email, password });
console.log(email);
},
toSplash() {
let baseUrl = 'http://localhost:3000/api/v1'
axios
.get(baseUrl).then(function (response) {
console.log(response + '=> redirect-success');
})
.catch(function (error) {
console.log(error);
})
}
}
};
</script>
<style scoped>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment