Created
February 22, 2017 07:57
-
-
Save em7v/50de921d94261ce69b47c6ec53cc4924 to your computer and use it in GitHub Desktop.
auth-vue-used Route_index.js - route/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class=" col-md-6 "> | |
<br> | |
<div class="panel panel-default"> | |
<div class="panel-heading">Авторизация</div> | |
<div class="panel-body"> | |
<div class="form-group"> | |
<label>Логин</label> | |
<input v-model="body.email" class="form-control" type="text"> | |
</div> | |
<div class="form-group"> | |
<label>Пароль</label> | |
<input v-model="body.password" class="form-control" type="password"> | |
</div> | |
<button v-on:click="login" class="btn btn-default">Войти</button> | |
</div> | |
</div> | |
</div> | |
</template> | |
<script> | |
import {mapActions} from 'vuex' | |
export default{ | |
data: () => { | |
return { | |
body: { | |
email: null, | |
password: null, | |
} | |
} | |
}, | |
methods: { | |
login() { | |
this.$auth.login({ | |
body: this.body, | |
success: function () { | |
}, | |
error: function () { | |
}, | |
rememberMe: true, | |
redirect: '/account' | |
}); | |
} | |
} | |
} | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import store from './store' | |
import App from './App.vue' | |
import router from './routes' | |
Vue.router = router; | |
App.router = Vue.router; | |
// Http | |
Vue.use(require('@websanova/vue-auth'), { | |
auth: require('@websanova/vue-auth/drivers/auth/bearer.js'), | |
http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'), | |
router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'), | |
rolesVar: 'type' | |
}); | |
new Vue({ | |
...App, | |
store | |
}).$mount('#app'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import VueRouter from 'vue-router' | |
// components | |
import Auth from '../components/Auth/index.vue' | |
import Main from '../components/Main/index.vue' | |
import PlaceView from '../components/Place/View.vue' | |
import Order from '../components/Order/index.vue' | |
import VueResource from 'vue-resource' | |
Vue.use(VueRouter); | |
Vue.use(VueResource); | |
Vue.http.options.root = 'http://site.dev/api/v1'; | |
// Vue.http.options.root = 'https://api-demo.websanova.com/api/v1'; | |
export default new VueRouter({ | |
mode: 'history', | |
routes: [ | |
{path: '/', component: Main}, | |
{path: '/places/:uid', component: PlaceView}, | |
{path: '/order', component: Order}, | |
{path: '/auth', component: Auth}, | |
] | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment