login + cookie set II

This commit is contained in:
ogerly 2021-02-23 15:07:44 +01:00
parent 2bd96339ff
commit fff03aa7bd
4 changed files with 21 additions and 19 deletions

View File

@ -3,9 +3,6 @@
<header class="border-t-4 border-blue-700 bg-white z-10 absolute w-full shadow-md"> <header class="border-t-4 border-blue-700 bg-white z-10 absolute w-full shadow-md">
</header> </header>
<div class="bg-gray-100 min-h-screen pt-40 text-lg"> <div class="bg-gray-100 min-h-screen pt-40 text-lg">
<!--<b-row v-show="this.$cookies.get('gdd_is_auth') == 'true'" class="justify-content-center">
<base-button type="warning" @click="logout">{{this.$store.state.user.email}} - Logout</base-button>
</b-row>-->
<router-view /> <router-view />
</div> </div>
</div> </div>
@ -16,37 +13,40 @@
export default { export default {
name: 'app', name: 'app',
created () { created () {
if (this.$cookies.get('gdd_is_auth') == 'true') { if (this.$cookies.get('gdd_is_auth') == 'true' && this.$store.state.is_auth == true) {
this.$store.state.user.email = this.$cookies.get('gdd_email') this.$store.state.user.email = this.$cookies.get('gdd_email')
this.$router.push('/KontoOverview')
// if ( this.$store.state.is_auth == false && this.$store.state.is_admin == false) {
// this.$router.push("/Landing")
// } else {
this.$router.push('/KontoOverview')
// }
}else { }else {
this.$router.push("/Landing") this.$router.push("/Landing")
} }
//if ( this.$store.state.is_auth == false && this.$store.state.is_admin == false) {
// this.$router.push("/Landing")
//}
//var user = { id:1, name:'Journal',session:'25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX' }; //var user = { id:1, name:'Journal',session:'25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX' };
//this.$cookies.set('user',user); //this.$cookies.set('user',user);
//// print user name //// print user name
console.log("APP.vue START created get cookie is_auth=>",this.$cookies.get('gdd_is_auth')) //console.log("APP.vue START created get cookie is_auth=>",this.$cookies.get('gdd_is_auth'))
}, },
methods: { methods: {
/* /*
login() { login() {
console.log("app.vue user login() : " + this.$store.state.is_auth) //console.log("app.vue user login() : " + this.$store.state.is_auth)
this.$store.commit('login') this.$store.commit('login')
//this.$router.push('/KontoOverview') //this.$router.push('/KontoOverview')
}, },
loginAsAdmin () { loginAsAdmin () {
console.log("app.vue admin login(): " + this.$store.state.is_admin) // console.log("app.vue admin login(): " + this.$store.state.is_admin)
this.$store.state.modals = true this.$store.state.modals = true
//this.$store.commit('loginAsAdmin') //this.$store.commit('loginAsAdmin')
//this.$router.push('/AdminOverview') //this.$router.push('/AdminOverview')
}, },
logout(){ logout(){
console.log("app.vue user logout() : ") // console.log("app.vue user logout() : ")
this.$store.commit('logout') this.$store.commit('logout')
} }
*/ */

View File

@ -28,9 +28,9 @@ router.beforeEach((to, from, next) => {
} }
//console.log("----------------") //console.log("----------------")
console.log("ROUTER.js to", to) //("ROUTER.js to", to)
console.log("ROUTER.js store.state.is_auth", store.state.is_auth) //console.log("ROUTER.js store.state.is_auth", store.state.is_auth)
console.log("ROUTER.js store.commit('isActive')", store.commit('isActive')) //console.log("ROUTER.js store.commit('isActive')", store.commit('isActive'))
//if (store.commit('isActive') ) { //if (store.commit('isActive') ) {
// next() // next()

View File

@ -57,13 +57,14 @@ export const store = new Vuex.Store({
//} //}
// console.log("STORE login() to " + state.is_auth) // console.log("STORE login() to " + state.is_auth)
}, },
creatUser( formdata) { creatUser( state, formdata) {
//console.log("Im Store creatUser() start " ) //console.log("Im Store creatUser() start " )
axios.post("http://localhost/login_api/createUser", formdata).then((ldata) => { axios.post("http://localhost/login_api/createUser", formdata).then((ldata) => {
//console.log("Im Store creatUser() axios then ", ldata); console.log("Im Store creatUser() axios then ", ldata);
// this.ldata = ldata.data; // this.ldata = ldata.data;
//return true return true
}, (error) => { }, (error) => {
console.log(error); console.log(error);
}); });

View File

@ -52,6 +52,7 @@ import DashboardContent from '../Layout/Content.vue';
import { FadeTransition } from 'vue2-transitions'; import { FadeTransition } from 'vue2-transitions';
export default { export default {
props: [],
components: { components: {
DashboardNavbar, DashboardNavbar,
ContentFooter, ContentFooter,