This file contains 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 OAuth from 'src/oauth' | |
import router from 'src/router' | |
let oAuth = new OAuth(); | |
router.beforeEach((to,from,next) => { | |
//If visiting login view but you already have logged in, you should not be able to see this view | |
if (to.name == 'app.login' && oAuth.isAuthenticated()) { | |
return next({ |
This file contains 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> | |
<q-layout | |
ref="layout" | |
view="lHh Lpr fff" | |
:left-class="{'bg-grey-2': true}" | |
> | |
<q-toolbar slot="header" class="glossy"> | |
<q-btn | |
flat | |
@click="$refs.layout.toggleLeft()" |
This file contains 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 http from 'axios' | |
import OAuth from 'src/oauth' | |
let oAuth = new OAuth(); | |
http.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest' | |
// Add a request interceptor | |
http.interceptors.request.use(function (config) { | |
config.headers['Authorization'] = oAuth.getAuthHeader() //Example: Bearer asf3132dfsfddffd |
This file contains 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' | |
Vue.use(VueRouter) | |
function load (component) { | |
// '@' is aliased to src/components | |
return () => import(`@/${component}.vue`) | |
} |
This file contains 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="login-view layout-padding"> | |
<q-card class="bg-white card" inline> | |
<q-card-title> | |
<h3>Login</h3> | |
<span slot="subtitle"></span> | |
</q-card-title> | |
<q-card-main> | |
<form @submit.prevent="login"> | |
<q-input v-model="form.username" stack-label="Email" /> |
This file contains 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 { | |
BASE_TOKEN, | |
API_URL, | |
} from 'config/auth' | |
export default { | |
TOKEN_URL: BASE_TOKEN + 'oauth/token', | |
CURRENT_USER_URL : API_URL + "users/user", | |
endpoints: { |
This file contains 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 Http from 'axios' | |
import API from 'api/routes' // We create a file to store all the endpoints | |
export default { | |
user : null, | |
destroySession(){ | |
this.user = null | |
}, | |
async currentUser(){ | |
if(this.user) { | |
return this.user |
This file contains 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 OAuth from 'oauth' | |
export default | |
{ | |
install(Vue, options){ | |
//In this way we'll expose our class in all Vue components | |
Vue.prototype.$oauth = new OAuth(); | |
Vue.mixin({ | |
mounted(){ |
This file contains 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
/*************************************************** | |
* [Quasar Cookies] http://quasar-framework.org/components/cookies.html | |
* [Quasar LocalStorage] http://quasar-framework.org/components/web-storage.html | |
**************************************************/ | |
import { Cookies, LocalStorage } from 'quasar' | |
import AuthService from './auth.service' |
This file contains 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
export const STATUS = 'local'; | |
let secrets = { | |
API_LOCAL : 'mysecretinlocal', | |
API_DEV : 'mysecretindev', | |
API_PRODUCTION : 'mysecretinproduction' | |
} | |
export const BASE_URL = { | |
'local' : 'http://localhost:8000/', |