README.markdown in simple_auth-1.0.2 vs README.markdown in simple_auth-1.1.0
- old
+ new
@@ -44,10 +44,27 @@
authentication
end
This will add some callbacks and password validations. It will also inject helper methods like `Model.authenticate`.
+Session is valid only when both `Model#authorized?` and `Controller#authorized?` methods return `true`, which is the default behavior. You can override these methods with your own rules:
+
+ class User < ActiveRecord::Base
+ authentication
+
+ def authorized?
+ deleted_at.nil?
+ end
+ end
+
+ class Admin::DashboardController < ApplicationController
+ private
+ def authorized?
+ current_user.admin?
+ end
+ end
+
After you set up the model, you can go to the controller.
class SessionsController < ApplicationController
def new
@user_session = SimpleAuth::Session.new
@@ -115,14 +132,24 @@
current_session # controller & views
when_logged(&block) # views
find_by_credential # model
find_by_credential! # model
-If you're having problems to use any helper, include the module <tt>SimpleAuth::Helper</tt> on your <tt>ApplicationHelper</tt>.
+If you're having problems to use any helper, include the module `SimpleAuth::Helper` on your `ApplicationHelper`.
module ApplicationHelper
include SimpleAuth::Helper
end
+
+### Translations
+
+These are the translations you'll need:
+
+ en:
+ simple_auth:
+ sessions:
+ need_to_be_logged: "You need to be logged"
+ invalid_credentials: "Invalid username or password"
Troubleshooting
---------------
You may receive strange errors related to `can't dup NilClass` or `You have a nil object when you didn't expect it!`. This will occur only on development mode and is an ActiveRecord bug that hasn't been fixed. Open the ActiveRecord file `activerecord-2.3.5/lib/active_record/base.rb` and comment the lines 411-412:
\ No newline at end of file