Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 171
- Log:
Initial import of Beast 0.9 from downloaded Tarball. Beast is a Ruby
On Rails based forum application. The original tarball came from the
following location:http://s3.amazonaws.com/beast-forum/beast-0.9.tar.gz
The forum post which announced this version's availability was at:
http://beast.caboo.se/forums/1/topics/446
- Author:
- rool
- Date:
- Fri Mar 02 15:51:55 +0000 2007
- Size:
- 2333 Bytes
1 | require 'digest/sha1' |
2 | class User < ActiveRecord::Base |
3 | has_many :moderatorships, :dependent => :destroy |
4 | has_many :forums, :through => :moderatorships, :order => 'forums.name' |
5 | |
6 | has_many :posts |
7 | has_many :monitorships |
8 | has_many :monitored_topics, :through => :monitorships, :conditions => ['monitorships.active = ?', true], :order => 'topics.replied_at desc', :source => :topic |
9 | |
10 | validates_presence_of :login, :email, :password_hash |
11 | validates_uniqueness_of :login, :email, :case_sensitive => false |
12 | # names that start with #s really upset me for some reason |
13 | validates_format_of :login, :with => /^[a-zA-Z]{2}(?:\w+)?$/ |
14 | validates_length_of :login, :minimum => 2 |
15 | |
16 | # names that start with #s really upset me for some reason |
17 | validates_format_of :display_name, :with => /^[a-zA-Z]{2}(?:[.'\-\w ]+)?$/ |
18 | validates_uniqueness_of :display_name, :case_sensitive => false |
19 | |
20 | validates_confirmation_of :password, :on => :create |
21 | before_validation { |u| u.display_name = u.login if u.display_name.blank? } |
22 | # first user becomes admin automatically |
23 | before_create { |u| u.admin = true if User.count == 0 } |
24 | |
25 | attr_reader :password |
26 | attr_protected :admin, :posts_count, :login, :created_at, :updated_at, :last_login_at, :topics_count, :activated |
27 | |
28 | def self.currently_online |
29 | user_ids = Session.find(:all, :select => "user_id", :conditions => ["user_id is NOT NULL and sessions.updated_at > ?", Time.now.utc-5.minutes]).map(&:user_id).uniq |
30 | User.find(user_ids) |
31 | end |
32 | |
33 | # we allow false to be passed in so a failed login can check |
34 | # for an inactive account to show a different error |
35 | def self.authenticate(login, password, activated=true) |
36 | find_by_login_and_password_hash_and_activated(login, Digest::SHA1.hexdigest(password + PASSWORD_SALT), activated) |
37 | end |
38 | |
39 | def password=(value) |
40 | write_attribute :password_hash, Digest::SHA1.hexdigest(value + PASSWORD_SALT) |
41 | @password = value |
42 | end |
43 | |
44 | def reset_login_key! |
45 | self.login_key = Digest::SHA1.hexdigest(Time.now.to_s + password_hash + rand(123456789).to_s).to_s |
46 | # this is not currently honored |
47 | self.login_key_expires_at = Time.now.utc+1.year |
48 | save! |
49 | login_key |
50 | end |
51 | |
52 | def moderator_of?(forum) |
53 | moderatorships.count(:all, :conditions => ['forum_id = ?', (forum.is_a?(Forum) ? forum.id : forum)]) == 1 |
54 | end |
55 | |
56 | end |