lib/zen/package/users/lib/users/model/user.rb in zen-0.2.5 vs lib/zen/package/users/lib/users/model/user.rb in zen-0.2.6
- old
+ new
@@ -18,10 +18,14 @@
#
# @author Yorick Peterse
# @since 0.1
#
class User < Sequel::Model
+ class << self
+ include ::Innate::Trinity
+ end
+
plugin :timestamps, :create => :created_at, :update => :updated_at
many_to_many :user_groups, :class => "Users::Model::UserGroup", :eager => [:access_rules]
one_to_many :access_rules, :class => "Users::Model::AccessRule"
@@ -47,10 +51,21 @@
end
user = self[:email => email]
if !user.nil? and user.password == password and user.status == 'open'
- ::Zen::Controller::BaseController.session[:user] = user
+ # Overwrite all the global settings with the user specific ones
+ ::Zen.settings.each do |k, v|
+ if user.respond_to?(k)
+ got = user.send(k)
+
+ if got.nil? or got.empty?
+ user.send("#{k}=", v)
+ end
+ end
+ end
+
+ action.node.session[:user] = user
return user
else
return false
end
end