lib/simple_auth/session.rb in simple_auth-1.0.2 vs lib/simple_auth/session.rb in simple_auth-1.1.0
- old
+ new
@@ -35,27 +35,28 @@
end
end
def self.find
session = new
+ return unless session.controller && session.controller.session[:record_id]
session.record = session.model.find_by_id(session.controller.session[:record_id])
if session.record
session
else
nil
end
end
def self.create(options = {})
- returning new(options) do |session|
+ new(options).tap do |session|
session.save
end
end
def self.create!(options = {})
- returning new(options) do |session|
+ new(options).tap do |session|
session.save!
end
end
def self.destroy!
@@ -91,10 +92,10 @@
def persisted?
!new_record?
end
def valid?
- if record
+ if record && record.authorized?
true
else
errors.add_to_base I18n.translate("simple_auth.sessions.invalid_credentials")
controller.session[:record_id] = nil
false