LightSwitch 2013 How To Use – GetExpandedUser

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);
                    }
               });
          });
     }
};

One thought on “LightSwitch 2013 How To Use – GetExpandedUser

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 142 other followers

%d bloggers like this: