Skip to content

Instantly share code, notes, and snippets.

@fernandofleury
Last active August 29, 2015 14:01
Show Gist options
  • Save fernandofleury/7fc5c9ea20450800c61e to your computer and use it in GitHub Desktop.
Save fernandofleury/7fc5c9ea20450800c61e to your computer and use it in GitHub Desktop.
// 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