README.markdown in simple_auth-0.1.2 vs README.markdown in simple_auth-0.1.3
- old
+ new
@@ -82,9 +82,40 @@
current_session.destroy if logged_in?
redirect_to root_path
end
end
+You can restrict access by using 2 macros:
+
+ class SignupController < ApplicationController
+ redirect_logged_user :to => "/"
+ end
+
+Here's some usage examples:
+
+ redirect_logged_user :to => proc { login_path }
+ redirect_logged_user :to => {:controller => "dashboard"}
+ redirect_logged_user :only => [:index], :to => login_path
+ redirect_logged_user :except => [:public], :to => login_path
+
+To require a logged user, use the `require_logged_user` macro:
+
+ class DashboardController < ApplicationController
+ require_logged_user :to => proc { login_path }
+ end
+
+Here's some usage examples:
+
+ require_logged_user :to => proc { login_path }
+ require_logged_user :to => {:controller => "session", :action => "new"}
+ require_logged_user :only => [:index], :to => login_path
+ require_logged_user :except => [:public], :to => login_path
+
+You can skip the `:to` option if you set it globally on your initializer:
+
+ SimpleAuth::Config.redirect_to = {:controller => "session", :action => "new"}
+ SimpleAuth::Config.redirect_to = proc { login_path }
+
There are some helpers:
logged_in? # controller & views
current_user # controller & views
current_session # controller & views
\ No newline at end of file