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/5055899 to your computer and use it in GitHub Desktop.
Save MandarinConLaBarba/5055899 to your computer and use it in GitHub Desktop.
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