Skip to content

Instantly share code, notes, and snippets.

@MandarinConLaBarba
Last active December 14, 2015 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MandarinConLaBarba/5055837 to your computer and use it in GitHub Desktop.
Save MandarinConLaBarba/5055837 to your computer and use it in GitHub Desktop.
var userName = view.$el.find('#txtUserName').val(),
password = view.$el.find('#txtPassword').val();
$.when(user.login())
.done(function() {
$.when(user.fetch())
.done(function() {
if (user.get("isAdmin")) {
view.showAdminPanel();
}
view.showAuthenticatedScreen();
});
}).fail(function(result) {
if (result.responseCode === "InvalidCredentials") {
view.showError("Invalid credentials!");
} else {
view.showError("Unable to login - unspecified error!");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment