Class: Member
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Member
- Defined in:
- lib/models/member.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#create_homedir ⇒ Object
Create user’s home dir if it’s not present.
- #homedir ⇒ Object
- #to_authpipe ⇒ Object
Class Method Details
.find_by_name_and_password(username, password) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/models/member.rb', line 6 def self.find_by_name_and_password(username, password) member = find_by_name(username) raise( IpcAuthpipe::AuthenticationFailed, 'invalid password' ) unless member.kind_of?(Member) && member.converge.valid_password?(password) member end |
Instance Method Details
#create_homedir ⇒ Object
Create user’s home dir if it’s not present
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/models/member.rb', line 20 def create_homedir unless File.exists?(homedir) FileUtils.mkdir_p(homedir, :mode => 0750) FileUtils.mkdir_p("#{homedir}/cur", :mode => 0750) FileUtils.mkdir_p("#{homedir}/new", :mode => 0750) FileUtils.mkdir_p("#{homedir}/tmp", :mode => 0750) FileUtils.chown(IpcAuthpipe::config.mail['owner_name'], IpcAuthpipe::config.mail['owner_group'], "#{homedir}/..") FileUtils.chown_R(IpcAuthpipe::config.mail['owner_name'], IpcAuthpipe::config.mail['owner_group'], homedir) end end |
#homedir ⇒ Object
15 16 17 |
# File 'lib/models/member.rb', line 15 def homedir (IpcAuthpipe::config.mail['home_dir'] % "#{name[0..0]}/#{name}").downcase end |
#to_authpipe ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/models/member.rb', line 31 def to_authpipe IpcAuthpipe::Log.debug "Dumping authpipe string for member data #{inspect}" stringdump = [ "UID=#{IpcAuthpipe::config.mail['owner_uid']}", "GID=#{IpcAuthpipe::config.mail['owner_gid']}", "HOME=#{homedir}/", "MAILDIR=#{homedir}/", "ADDRESS=#{(IpcAuthpipe::config.mail['address_format'] % name).downcase}", "." ].join("\n")+"\n" IpcAuthpipe::Log.debug "Authpipe dump: #{stringdump.inspect}" stringdump end |