Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 24
- Log:
Initial import of Collaboa 0.5.6 from downloaded Tarball. Collaboa is
a Ruby On Rails based bug tracker and SVN repository browsing tool.
- Author:
- adh
- Date:
- Mon Jul 24 21:54:39 +0100 2006
- Size:
- 1517 Bytes
1 | # this model expects a certain database layout and its based on the name/login pattern. |
2 | class User < ActiveRecord::Base |
3 | |
4 | validates_length_of :login, :within => 3..40 |
5 | validates_length_of :password, :within => 5..40 |
6 | validates_presence_of :login, :password |
7 | validates_presence_of :password_confirmation, :on => :create |
8 | validates_uniqueness_of :login, :on => :save |
9 | validates_confirmation_of :password, :on => :create |
10 | validates_length_of :new_password, :within => 5..40, :allow_nil => true |
11 | validates_confirmation_of :new_password, :on => :update |
12 | |
13 | attr_reader :new_password |
14 | |
15 | def new_password=(pw) |
16 | @new_password = pw |
17 | end |
18 | |
19 | before_validation { |record| record.new_password = nil if record.new_password.empty? rescue nil } |
20 | before_validation { |record| record.new_password_confirmation = nil if record.new_password_confirmation.empty? rescue nil } |
21 | before_validation :crypt_new_password |
22 | |
23 | before_create :crypt_password |
24 | |
25 | def self.authenticate(login, pass) |
26 | return nil if login == 'Public' |
27 | find_first ["login = ? AND password = ?", login, sha1(pass)] |
28 | end |
29 | |
30 | def change_password(pass) |
31 | update_attribute :password, self.class.sha1(pass) |
32 | end |
33 | |
34 | protected |
35 | def self.sha1(pass) |
36 | Digest::SHA1.hexdigest("c-o-l-l-a-b-o-a--#{pass}--") |
37 | end |
38 | |
39 | def crypt_password |
40 | write_attribute :password, self.class.sha1(password) |
41 | end |
42 | |
43 | def crypt_new_password |
44 | write_attribute("password", self.class.sha1(new_password)) if new_password |
45 | end |
46 | end |