19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/wristband.rb', line 19
def wristband(options={})
options[:login_with] ||= [:email]
options[:before_authentication] ||= []
options[:after_authentication] ||= []
options[:has_authorities] ||= false
options[:roles] ||= []
options[:legacy_password] ||= {}
class_eval do
include Wristband::UserExtensions
options[:password_column] ||= :password_hash
attr_accessor :password
attr_accessor :password_confirmation
before_save :encrypt_password
unless options[:roles].blank?
options[:roles].each do |role|
define_method "is_#{role}?" do
self.role.to_s == role.to_s
end
end
end
class << self
attr_accessor :wristband
end
end
self.wristband = {
:login_with_fields => [options[:login_with]].flatten,
:before_authentication_chain => [options[:before_authentication]].flatten,
:after_authentication_chain => [options[:after_authentication]].flatten,
:password_column => options[:password_column],
:roles => options[:roles],
:legacy_password => options[:legacy_password]
}
if options[:has_authorities]
self.wristband[:authority_class] = UtilityMethods.interpret_class_specification(self, options[:has_authorities])
end
end
|