Class: ODDB::State::Admin::PasswordLost

Inherits:
Global
  • Object
show all
Defined in:
src/state/admin/password_lost.rb

Constant Summary

VIEW =
View::Admin::PasswordLost

Constants inherited from Global

DIRECT_EVENT, GLOBAL_MAP, HOME_STATE, LIMITED, PRINT_STATES, READONLY_STATES, RESOLVE_STATES, REVERSE_MAP, VIEW, ZONE_NAVIGATION

Constants included from UmlautSort

FILTER_PAIRS

Instance Method Summary (collapse)

Methods inherited from Global

#_search_drugs, #_search_drugs_state, #_trigger, #add_to_interaction_basket, #allowed?, #atc_chooser, #checkout, #clear_interaction_basket, #creditable?, #direct_request_path, #doctorlist, #download, #export_csv, #extend, #fachinfo, #feedbacks, #help_navigation, #home_navigation, #home_state, #hospitallist, #interaction_basket, #limit_state, #limited?, #logout, #navigation, #notify, #password_reset, #paypal_return, #powerlink, #print, #proceed_download, #proceed_poweruser, #resolve, #resolve_state, #rss, #search, #show, #snapback_event, #sort, #sponsorlink, #suggest_address, #switch, #unique_email, #user_input, #user_navigation, #ywesee_contact, #zone_navigation, #zones

Methods included from LoginMethods

#autologin, #login

Methods included from UmlautSort

#sort_model, #umlaut_filter

Instance Method Details

- (Object) notify_user(email, token, time)



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'src/state/admin/password_lost.rb', line 29

def notify_user(, token, time)
  lnf = @session.lookandfeel
  config = ODDB.config
  mail = RMail::Message.new
  header = mail.header
  recipient = header.to = 
  header.from = config.mail_from
  header.subject = lnf.lookup(:password_lost_subject)
  url = lnf._event_url(:password_reset, {:token => token, :email => recipient})
  mail.body = lnf.lookup(:password_lost_body, recipient, url, 
    time.strftime(lnf.lookup(:time_format_long)))
  recipients = [recipient] + config.mail_to
  Net::SMTP.start(config.smtp_server, config.smtp_port, config.smtp_domain,
                  config.smtp_user, config.smtp_pass,
                  config.smtp_authtype) { |smtp|
    recipients.each { |recipient|
      smtp.sendmail(mail.to_s, config.smtp_user, recipient)
    }
  }
  recipients
end

- (Object) password_request



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'src/state/admin/password_lost.rb', line 14

def password_request
  input = user_input(:email, :email)
   = input[:email]
  unless(error?)
    token = Digest::MD5.hexdigest(rand.to_s)
    #hashed = Digest::MD5.hexdigest(token)
    time = Time.now + 48 * 60 * 60
    @session.yus_grant(, 'reset_password', token, time)
    notify_user(, token, time)
    Confirm.new(@session, :password_request_confirm)
  end
rescue Yus::UnknownEntityError
  @errors.store(:email, create_error('e_unknown_user', :email, ))
  self
end