-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unnecessary vuex stores remove, code structure improvement
using tab instead of space, tab size 2, unnecessary vuex store mudule removed, used noty as notification plugin, better code structure
- Loading branch information
1 parent
d477940
commit 5f6a337
Showing
33 changed files
with
758 additions
and
962 deletions.
There are no files selected for viewing
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,58 @@ | ||
import $ from 'jquery'; | ||
import _ from 'lodash'; | ||
import Vue from 'vue'; | ||
import VueNoty from 'vuejs-noty'; | ||
import axios from 'axios'; | ||
|
||
window.$ = window.jQuery = $; | ||
window.axios = axios; | ||
require('bootstrap-sass'); | ||
|
||
Vue.use(VueNoty, { | ||
progressBar: false, | ||
layout: 'bottomRight', | ||
theme: 'bootstrap-v3', | ||
timeout: 5000 | ||
}); | ||
|
||
import router from './routes'; | ||
import router from './router'; | ||
import store from './store/index'; | ||
import App from './components/App.vue'; | ||
import jwtToken from './helpers/jwt-token'; | ||
|
||
axios.interceptors.request.use(config => { | ||
config.headers['X-CSRF-TOKEN'] = window.Laravel.csrfToken; | ||
config.headers['X-Requested-With'] = 'XMLHttpRequest'; | ||
config.headers['X-CSRF-TOKEN'] = window.Laravel.csrfToken; | ||
config.headers['X-Requested-With'] = 'XMLHttpRequest'; | ||
|
||
if(jwtToken.getToken()) { | ||
config.headers['Authorization'] = 'Bearer '+ jwtToken.getToken(); | ||
} | ||
if (jwtToken.getToken()) { | ||
config.headers['Authorization'] = 'Bearer ' + jwtToken.getToken(); | ||
} | ||
|
||
return config; | ||
return config; | ||
}, error => { | ||
return Promise.reject(error); | ||
return Promise.reject(error); | ||
}); | ||
|
||
axios.interceptors.response.use(response => { | ||
return response; | ||
return response; | ||
}, error => { | ||
let errorResponseData = error.response.data; | ||
let errorResponseData = error.response.data; | ||
|
||
const errors = ["token_invalid", "token_expired", "token_not_provided"]; | ||
|
||
if(errorResponseData.error && (errorResponseData.error === "token_invalid" || errorResponseData.error === "token_expired" || errorResponseData.error === 'token_not_provided')) { | ||
store.dispatch('logoutRequest') | ||
.then(()=> { | ||
router.push({name: 'login'}); | ||
}); | ||
} | ||
if (errorResponseData.error && errors.includes(errorResponseData.error)) { | ||
store.dispatch('unsetAuthUser') | ||
.then(() => { | ||
jwtToken.removeToken(); | ||
router.push({name: 'login'}); | ||
}); | ||
} | ||
|
||
return Promise.reject(error); | ||
return Promise.reject(error); | ||
}); | ||
|
||
Vue.component('app', App); | ||
|
||
const app = new Vue({ | ||
router, | ||
store | ||
router, | ||
store | ||
}).$mount('#app'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,21 @@ | ||
<template> | ||
<div> | ||
<top-menu></top-menu> | ||
<notification></notification> | ||
<transition name="fade" mode="out-in"> | ||
<router-view></router-view> | ||
</transition> | ||
<app-footer></app-footer> | ||
</div> | ||
<div> | ||
<top-menu></top-menu> | ||
<transition name="fade" mode="out-in"> | ||
<router-view></router-view> | ||
</transition> | ||
<app-footer></app-footer> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import TopMenu from './shared/TopMenu.vue' | ||
import Notification from './shared/Notification.vue' | ||
import AppFooter from './shared/AppFooter.vue' | ||
import jwtToken from './../helpers/jwt-token'; | ||
import TopMenu from './shared/TopMenu.vue'; | ||
import AppFooter from './shared/AppFooter.vue'; | ||
export default { | ||
created() { | ||
if(jwtToken.getToken()) { | ||
this.$store.dispatch('setAuthUser'); | ||
} | ||
}, | ||
components: { | ||
'top-menu': TopMenu, | ||
'notification': Notification, | ||
'app-footer': AppFooter | ||
} | ||
} | ||
export default { | ||
components: { | ||
'top-menu': TopMenu, | ||
'app-footer': AppFooter | ||
} | ||
} | ||
</script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
<template> | ||
<div class="container"> | ||
<div class="jumbotron"> | ||
<h1 v-once>{{siteName}}</h1> | ||
<p>Starter Boilerplate SPA made with Laravel 5.5, JWT Auth, Vue 2, Vue-router 3, Vuex 3, Axios and love</p> | ||
</div> | ||
</div> | ||
<div class="container"> | ||
<div class="jumbotron"> | ||
<h1 v-once>{{siteName}}</h1> | ||
<p>Starter Boilerplate SPA made with Laravel 5.5, JWT Auth, Vue 2, Vue-router 3, Vuex 3, Axios and love</p> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import {siteName} from './../../config'; | ||
import {siteName} from './../../config'; | ||
export default { | ||
data() { | ||
return { | ||
siteName: siteName | ||
} | ||
} | ||
} | ||
export default { | ||
data() { | ||
return { | ||
siteName: siteName | ||
} | ||
} | ||
} | ||
</script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,42 @@ | ||
<template> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
<div class="page-header"> | ||
<h1>Login</h1> | ||
</div> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur corporis deserunt, dolorem eligendi esse eum illo illum inventore libero minus nam numquam officiis praesentium quas quasi repudiandae sed tempore voluptatibus?</p> | ||
</div> | ||
<div class="col-md-4"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Login</div> | ||
<div class="panel-body"> | ||
<login-form></login-form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
<div class="page-header"> | ||
<h1>Login</h1> | ||
</div> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur corporis deserunt, dolorem eligendi esse eum illo illum inventore libero minus nam numquam officiis praesentium quas quasi repudiandae sed tempore voluptatibus?</p> | ||
</div> | ||
<div class="col-md-4"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Login</div> | ||
<div class="panel-body"> | ||
<login-form @loginSuccess="loginSuccess"></login-form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import LoginForm from './../login/LoginForm.vue' | ||
import LoginForm from './../login/LoginForm.vue' | ||
import jwtToken from "../../helpers/jwt-token"; | ||
import {mapActions} from "vuex"; | ||
export default { | ||
components: { | ||
'login-form': LoginForm | ||
} | ||
} | ||
export default { | ||
components: { | ||
'login-form': LoginForm | ||
}, | ||
methods: { | ||
...mapActions([ | ||
'setAuthUser' | ||
]), | ||
loginSuccess(data) { | ||
jwtToken.setToken(data.token); | ||
this.setAuthUser(data.user); | ||
this.$router.push({name: 'profile'}); | ||
} | ||
} | ||
} | ||
</script> |
Oops, something went wrong.