Class: Goldberg::User
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Model
included
#associated_valid?, #no_errors_in_associated?, #save_associated, #save_associated!, #save_with_unsaved_flag, #to_label, #unsaved=, #unsaved?
Instance Attribute Details
#clear_password ⇒ Object
Returns the value of attribute clear_password.
12
13
14
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 12
def clear_password
@clear_password
end
|
#confirm_password ⇒ Object
Returns the value of attribute confirm_password.
13
14
15
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 13
def confirm_password
@confirm_password
end
|
Class Method Details
.random_password ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 59
def random_password
letters = ('A' .. 'Z').to_a + ('a' .. 'z').to_a
password = (1 .. 6).collect do
letters[ (rand * letters.length).to_i ]
end
password.to_s
end
|
Instance Method Details
#after_save ⇒ Object
29
30
31
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 29
def after_save
self.clear_password = nil
end
|
#before_save ⇒ Object
23
24
25
26
27
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 23
def before_save
if self.self_reg_confirmation_required
self.set_confirmation_key
end
end
|
#before_validation ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 15
def before_validation
if self.clear_password self.password_salt = self.object_id.to_s + rand.to_s
self.password = Digest::SHA1.hexdigest(self.password_salt +
self.clear_password)
end
end
|
#check_password(clear_password) ⇒ Object
33
34
35
36
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 33
def check_password(clear_password)
self.password == Digest::SHA1.hexdigest(self.password_salt.to_s +
clear_password)
end
|
#email_valid? ⇒ Boolean
43
44
45
46
47
48
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 43
def email_valid?
self.email &&
self.email.length > 0 &&
self.email =~ /\A.+@[^\.].*\.[a-z]{2,}\z/
end
|
#get_start_path ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 50
def get_start_path
if self.start_path and self.start_path.length > 0
self.start_path
else
self.role.get_start_path
end
end
|
#set_confirmation_key ⇒ Object
38
39
40
41
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/user.rb', line 38
def set_confirmation_key
self.confirmation_key = Digest::SHA1.hexdigest(self.object_id.to_s +
rand.to_s)
end
|