Last active
December 14, 2015 08:09
-
-
Save MandarinConLaBarba/5055899 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
sebastian.flow("flows.examples.splash") | |
.step("get-form-data", function() { | |
var userName = this.view.$el.find('#txtUserName').val(), | |
password = this.view.$el.find('#txtPassword').val(); | |
return $.Deferred().resolve(userName, password); | |
}) | |
.step("login-user", function(userName, password) { | |
this.user.set("userName", userName); | |
this.user.set("password", password); | |
return this.user.login(); | |
}) | |
.step("fetch-user", function() { | |
return this.user.fetch(); | |
}) | |
.step("show-authenticated-screen", function() { | |
this.view.showAuthenticatedScreen(); | |
}) | |
.step("show-admin-screen", function() { | |
if (this.user.get("isAdmin")) { | |
this.view.showAdminPanel(); | |
} | |
}) | |
.onFailure("InvalidCredentials").handleWith(function() { | |
this.view.showError("Invalid credentials!"); | |
}) | |
.onFailure().handleWith(function() { | |
this.view.showError("Unable to login - unspecified error!"); | |
}) | |
.context({ | |
view : view, | |
user : user | |
}) | |
.begin(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment