| 
					
				 | 
			
			
				@@ -1,13 +1,17 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { HTTP } from 'vuejs/rest/http-axios' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import qs from 'querystring' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   namespaced: true, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // initial state 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   state : { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    isloggedin: false, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    username: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    token: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    uid:null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // username: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    mail:'', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    token: null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    logout_token: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // isloggedin: false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // getters 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -15,45 +19,48 @@ export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // mutations 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   mutations : { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // setUser (state, posts) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //   state.all = posts 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // setOpened (state, post) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //   state.opened = post 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // clearOpened (state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //   state.opened = null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    setUser (state, data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      state.uid = data.current_user.uid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // state.username = data.username 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      state.mail = data.current_user.mail 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      state.token = data.csrf_token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      state.logout_token = data.logout_token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    setLoggedOut (state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      state.uid= null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      state.mail = '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      state.token = null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      state.logout_token = null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // actions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   actions : { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    getToken ({ commit, state }, data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      // console.log('getToken data', data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      let config = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        headers: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          "Content-Type": "application/json" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      // console.log('data', data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      // console.log('config', config) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      HTTP.post('/user/login?_format=json', data, config) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        .then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          console.log('response', response) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          // cb(response.data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    getToken ({ commit, state }, credentials) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      HTTP.post('/user/login?_format=json', credentials) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        .then(({ data }) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          console.log('data', data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          commit('setUser', data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        .catch(( error ) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            console.log('Issue with login', error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Promise.reject(error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    userLogout ({ commit, state }) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let credentials = qs.stringify({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        token: state.token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      HTTP.post('/user/logout', credentials) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        .then((resp) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          console.log('resp', resp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          commit('setLoggedOut') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        .catch(({ error }) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            console.log('Issue with login', error); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Promise.reject(error); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        .catch(( error ) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            console.log('Issue with logout', error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Promise.reject(error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // logout ({ commit }) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |