Last active
August 29, 2015 14:01
-
-
Save fernandofleury/7fc5c9ea20450800c61e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// exemplo de data | |
{ | |
token: "Token retornado do back-end", | |
profile: "Perfil retornado do back-end" | |
} | |
app.storeUserData = function(data) { | |
sessionStorage.setItem('userData', JSON.stringify(data)); | |
}; | |
app.getUserData = function() { | |
return JSON.parse(sessionStorage.getItem('userData')); | |
}; | |
app.sendRequest = function(action, data) { | |
jQuery.support.cors = true; | |
var data = (typeof data !== 'undefined' ? $.extend(data, app.getUserData()) : {}); | |
$.ajax({ | |
url: '/Facade/'+action, | |
data: JSON.stringify(data), | |
type: "POST", | |
dataType: "json", | |
contentType: "application/json; charset=utf-8" | |
}); | |
} | |
app.showContent = function(profile) { | |
if(profile === 'BackOffice') { | |
console.log('you are not allowed'); | |
} else if(profile === 'Helpdesk') { | |
console.log('welcome'); | |
} else { | |
console.log('you are not allowed'); | |
} | |
}; | |
app.showContent(app.getUserData().profile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment