From a3bef880a032ea032a24d8f83fa3da347567e9ee Mon Sep 17 00:00:00 2001 From: Juan Carlos Ruvalcaba Date: Sat, 24 Apr 2021 16:50:04 -0700 Subject: [PATCH] -Remove old user login handling way -Read/write theme use in pesistent way --- src/app.f7.html | 11 +++- src/js/controllers/users.js | 94 ------------------------------ src/pages/home/panel-left.f7.html | 13 ++++- src/pages/home/panel-right.f7.html | 19 +++--- 4 files changed, 29 insertions(+), 108 deletions(-) delete mode 100644 src/js/controllers/users.js diff --git a/src/app.f7.html b/src/app.f7.html index 035cc44..eea2136 100644 --- a/src/app.f7.html +++ b/src/app.f7.html @@ -9,11 +9,20 @@ diff --git a/src/js/controllers/users.js b/src/js/controllers/users.js deleted file mode 100644 index 0a2c8e3..0000000 --- a/src/js/controllers/users.js +++ /dev/null @@ -1,94 +0,0 @@ -import AjaxHandler from '../api/AjaxHandler.js'; -import endpoint from '../api/ConnectionMode.js'; - -let User = { - async getLogin (userdata, password){ - try{ - let params = { - method : "POST", - url : `${endpoint}/user/login`, - data : { - UserData : userdata, - UserPassword : password, - }, - dataType : "json", - } - var ajax = new AjaxHandler(); - let result = await ajax.request(params); - return result; - } - catch(err){ - throw err; - } - }, - async checkLogin(user, pass){ - if (user === "" || pass === ""){ - throw new Error ("Ingrese usuario/contraseƱa"); - } - let result = await this.getLogin(user, pass); - - if (result.data.status === false){ - throw new Error (userdata.message); - } - - let userData = result.data; - let params = { //fixed - url: "", - method : "GET", - contentType: "application/x-www-form-urlencoded", - crossDomain: true, - dataType: "json", - headers: { "Authorization" : userData.data.token } - }; - localStorage.setItem("request_params", JSON.stringify(params)); - delete userData.data.token; - userData.data["userPermissions"] = [1, 4, 14, 15]; //Owner, Customer, Seller, Deliverer - localStorage.setItem("userData",JSON.stringify(userData.data)); - - return true; - }, - isLogged(){ - let x = ["userData"]; - let isLogged = true; - for (var i=0; i expirationDate.getTime()){ - return false; - } - else if (today < expirationDate){ - } - else{ - } - return true; - }, - logOff (){ - localStorage.removeItem("userData"); - localStorage.removeItem("request_params"); - location.reload(); - }, - decodeJWT (token) { - var base64Url = token.split('.')[1]; - var base64 = decodeURIComponent(atob(base64Url).split('').map(function(c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); - }).join('')); - - return JSON.parse(base64); - }, -}; - -export default User; diff --git a/src/pages/home/panel-left.f7.html b/src/pages/home/panel-left.f7.html index a83b4a2..7850e1e 100644 --- a/src/pages/home/panel-left.f7.html +++ b/src/pages/home/panel-left.f7.html @@ -126,11 +126,11 @@