Skip to content

Commit

Permalink
Redirect back after login
Browse files Browse the repository at this point in the history
  • Loading branch information
quirkey committed Mar 23, 2010
1 parent 823aece commit f572434
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion _attachments/index.html
Expand Up @@ -37,7 +37,8 @@
Swinger was created by <a href="http://www.quirkey.com">Aaron Quint</a>
and is powered by <a href="http://code.quirkey.com/sammy">Sammy.js</a>,
<a href="http://couchdb.apache.org">CouchDB</a> and
<a href="http://github.com/couchapp/couchapp">Couchapp</a>.
<a href="http://github.com/couchapp/couchapp">Couchapp</a>.
It's 100% <a href="http://github.com/quirkey/swinger">Open Source</a>.
</div>
<div id="modal-loader" class="modal" style="display:none;"><img src="images/loader-large-black.gif" alt="Loading" /></div>
<div id="modal-notification" class="modal" style="display:none;"><div class="message">&nbsp;</div><br /><button>Close</button></div>
Expand Down
9 changes: 6 additions & 3 deletions _attachments/javascripts/app.js
Expand Up @@ -549,9 +549,10 @@
});
});

this.before({only: /\#\/(create|new|preso\/([^\/]+)\/edit)/}, function() {
this.before({only: /\#\/(create|new|preso\/([^\/]+)\/edit)$/}, function() {
if (!User.isLoggedIn()) {
showNotification('error', 'Sorry, please login or signup to create a presentation.');
this.app.last_location_before_redirect = this.path;
this.redirect('#/login');
return false;
}
Expand Down Expand Up @@ -593,7 +594,8 @@
this.post('#/login', function(e) {
User.login(this.params['name'], this.params['password'], function(user) {
showNotification('success', 'Thanks for logging in, ' + user.name + '!');
e.redirect('#/');
e.redirect(e.app.last_location_before_redirect || '#/');
e.app.last_location_before_redirect = null;
})
});

Expand All @@ -616,7 +618,8 @@
// create
User.signup(this.params['name'], this.params['email'], this.params['password'], function() {
showNotification('success', 'Thanks for signing up! You can start making presentations now.');
e.redirect('#/');
e.redirect(e.app.last_location_before_redirect || '#/');
e.app.last_location_before_redirect = null;
});
} else {
showNotification('error', 'Please fill out the entire form.');
Expand Down

0 comments on commit f572434

Please sign in to comment.