I am using the User plugin and have added a path to a page I want to be public, using this example. But it just ignores it. I have tried different strings in the url of the page but it doesnt seem to work…
app.use(plugins.User, {
model: session,
public: path => path.indexOf("top/data") > -1
});
Here is my session model…
import { getUrl } from "../environments"
const url = getUrl("sts") + "/api/users";
webix.attachEvent("onBeforeAjax",
function(mode, url, data, request, headers, files, promise){
headers["Authorization"] = "Bearer " + webix.storage.local.get("my_bearer");
}
);
webix.attachEvent("onAjaxError", function(xhr){
if (xhr.status == 401 ){
logout();
window.location.href = "/#!/login";
}
});
function status(){
var bearer = webix.storage.local.get("my_bearer");
if( bearer === undefined || bearer === null){
return webix.promise.reject(null).fail(function(error){
resolve(null);
});
}
var user = webix.storage.local.get("my_user");
if( user === undefined || user === null){
return webix.promise.reject(null).fail(function(error){
resolve(null);
});
}else{
return webix.promise.resolve( user );
}
}
function current(){
return webix.ajax().get(url + "/current")
.then(a => {
a.json();
webix.storage.local.put("my_user", a.json());
});
}
function login(user, pass){
return webix
.ajax()
.headers({"Content-type":"application/json"})
.post( url + "/login", { "email": user, "password" : pass }
)
.then(a => {
webix.storage.local.put("my_bearer", a.json().tokenString );
current();
return a.json()
});
}
function logout(){
return new webix.promise((resolve, reject) => {
webix.storage.local.remove("my_bearer");
webix.storage.local.remove("my_user");
resolve(null)
});
}
export default {
status, login, logout
}