Skip to content
Snippets Groups Projects
Commit 298055bd authored by emreaydogdu's avatar emreaydogdu
Browse files

expired

parent 14643535
No related branches found
No related tags found
No related merge requests found
......@@ -28,18 +28,14 @@ export default {
return this.$store.state.auth.status.loggedIn;
},
currentUser() {
return this.$store.state.auth.user;
},
},
created() {
this.update()
this.navUpdate();
},
methods: {
update() {
navUpdate (){
if (!this.loggedIn) {
this.sidebarStyle = "display: none";
this.contentClass = "content col-md-12";
......
......@@ -50,10 +50,6 @@ export default {
*/
},
logOut: function() {
this.$store.dispatch('auth/logout');
this.$router.push('/login');
}
}
......
......@@ -72,7 +72,9 @@ export default {
reg: /^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$/,
password: "",
passwordFieldType: 'password',
passwordToggleStyle: "password_toggle_img"
passwordToggleStyle: "password_toggle_img",
}
},
......@@ -113,9 +115,10 @@ export default {
if (this.user.username && this.user.password) {
this.$store.dispatch('auth/login', this.user).then(
() => {
localStorage.setItem('cronJob', 0);
this.$crontab.startCrontab();
this.$crontab.execJob('counter')
this.$router.push('/home');
this.$parent.update();
this.$parent.navUpdate();
}
);
}
......
......@@ -12,7 +12,7 @@
<router-link to="/layouts"><a class="navA">Vorlagen</a></router-link><br>
<router-link to="/calendar"><a class="navA">Kalender</a></router-link><br>
<router-link to="/register"><a class="navA">neuen Nutzer anlegen</a></router-link>
<a class="nav-link sidebar-bottom" href @click.prevent="logOut()">
<a class="nav-link sidebar-bottom" href @click.prevent="logout">
<a href="/logout"><a class="navA">Abmelden</a></a>
</a>
</div>
......@@ -24,15 +24,16 @@ export default {
name: "SideMenu",
methods: {
logOut: function() {
logout: function () {
this.$store.dispatch('auth/logout').then(
() => {
localStorage.setItem('cronJob', 0);
this.$router.push('/login');
this.$parent.update();
this.$parent.navUpdate();
},
error => {
this.message = (error.response && error.response.data) || error.message || error.toString();
console.log(this.message)
}
);
}
......
<template>
<div class="content col-md-12">
<h1>{{counter}}</h1>
<h1>{{data}}</h1>
<h1>{{message}}</h1>
<h1>{{service}}</h1>
</div>
</template>
<script>
export default {
name: "Teachers",
data(){
return{
data: "Placeholder",
counter: JSON.parse(localStorage.getItem('cronJob')),
cronJob: this.$crontab.addJob({
name: 'counter',
interval: {
seconds: '/1',
},
job: this.countUp
})
message: "not Expired",
service: 0,
}
},
created() {
this.getData();
this.$crontab.execJob('counter');
},
methods:{
countUp () {
this.counter += 1
if (this.counter >= 60){
this.$crontab.deleteJob('counter');
//alert("Geh nachhcause");
}
localStorage.setItem('cronJob', this.counter);
},
getData () {
this.$store.dispatch('user/getHello').then(
() => {
(response) => {
console.log(response.status)
this.data = this.$store.state.user.response;
},
error => {
this.message =
(error.response && error.response.data) ||
error.message ||
error.toString();
this.successful = false;
(error) => {
this.message = error;
console.log(error)
}
);
}
},
}
}
</script>
......
......@@ -16,6 +16,11 @@ import { faHome, faUser, faUserPlus, faSignInAlt, faSignOutAlt } from '@fortawes
library.add(faHome, faUser, faUserPlus, faSignInAlt, faSignOutAlt);
VueCrontab.setOption({
interval: 200,
auto_start: false
})
Vue.config.productionTip = false;
Vue.use(VueCrontab)
Vue.use(BootstrapVue)
......
......@@ -63,7 +63,7 @@ const router = new Router({
})
router.beforeEach((to, from, next) => {
const publicPages = ['/login'];
const publicPages = ['/login', '/register'];
const authRequired = !publicPages.includes(to.path);
const loggedIn = localStorage.getItem('user');
......
......@@ -14,6 +14,7 @@ class AuthService {
.then(response => {
if (response.data.idToken) {
localStorage.setItem('user', JSON.stringify(response.data));
localStorage.setItem('cronJob', 0);
}
return response.data;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment