We’ve been asked how to use some of our AccountController features. One very handy, which everyone should start to use, is the GetExpandedUser call. With this call you can easily get user data that includes Roles and Permissions and have it saved into the global application space. This allows you to easily do some client side branching without going back to the server.
Obviously this is only valid for the current user session but if, when logging in, the user opts in to “Remember Me”, it will easily pull the data when the new session starts.
Typically you’ll add this to your startup screen created method.
myapp.UserMenu.created = function (screen) {
// If we don't have a global user, go get the logged in user data
if (myapp.user == undefined) {
$.getJSON("/rpc/Account/LoggedInUser").then(function (data) {
$.getJSON("/rpc/Account/GetExpandedUser/" + data.Name, function (userData) {
if (userData != undefined) {
myapp.user = $.parseJSON(userData);
}
});
});
}
};
[…] LightSwitch 2013 How To Use – GetExpandedUser […]