Don't give an error when you access the login page when you are logged in. Instead...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Thu, 11 Dec 2008 15:05:53 +0000 (15:05 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Thu, 11 Dec 2008 15:05:53 +0000 (15:05 +0000)
app/controllers/user_controller.rb

index b9ed5409658ac85a614124961f54ee1da77f6f12..825c9263582c8f66076cb891c495ef39610f3e3c 100644 (file)
@@ -117,6 +117,14 @@ class UserController < ApplicationController
   end
 
   def login
+    if session[:user]
+      # The user is logged in already, if the referer param exists, redirect them to that
+      if params[:referer]
+        redirect_to params[:referer]
+      else
+        redirect_to :controller => 'site', :action => 'index'
+      end
+    end
     @title = 'login'
     if params[:user]
       email_or_display_name = params[:user][:email]