JSFiddle - React, Tailwind, and code Playground
JavaScript
function activate() {
console.log(appsecurity.userInfo());
if (typeof (appsecurity.userInfo()) !== 'undefined') {
return privateAccess();
}
if (typeof (appsecurity.userInfo()) === 'admin') {
return adminAccess();
} else {
return publicAccess();
}
// ** Note this never gets called due to the if/return above
router.on('router:route:not-found', function (fragment) {
logError('No Route Found', fragment, true);
});
}
function adminAccess() {
alert("please define the admin route here!");
}
function routes() {
var routesArray = [
{ route: ['', 'uebersicht'], moduleId: 'overview', title: 'Ăśbersicht', nav: 1, authorize: ["User", "Administrator"] },
{ route: 'marktplatz*details', moduleId: 'marketplace/index', title: 'Marktplatz', nav: 2, hash: '#marktplatz', authorize: ["User", "Administrator"] },
{ route: 'bewertungen', moduleId: 'rating', title: 'Bewertungen', nav: 3, hash: '#bewertungen', authorize: ["User", "Administrator"] },
{ route: 'profil*details', moduleId: 'profile/index', title: 'Profil', nav: 4, hash: '#profil', authorize: ["User", "Administrator"] },
{ route: 'breezeexample', moduleId: 'breezeexample', title: 'breezeexample', nav: 5, authorize: ["User", "Administrator"] },
//{ route: 'jaydataexample', moduleId: 'jaydataexample', title: 'jaydataexample', nav: 6 }
{ route: 'jaydataexample', moduleId: 'jaydataexample', title: 'jaydataexample', nav: 6, authorize: ["User", "Administrator"] },
];
var result = (function (authTypes) {
var results = [], i, j, k, works;
for (i = 0; i < routesArray.length; i++) {
if (routesArray[i] && routesArray[i].authorize && routesArray[i].authorize.length) {
works = false;
for (j = 0; j < routesArray[i].authorize.length; j++) {
for (k = 0; k < authTypes.length; k++) {
works = works ||...