Class: UsersController

Inherits:
ApplicationController show all
Defined in:
lib/generators/jinda/templates/app/controllers/jinda_org/users_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#prepare_meta_tags

Instance Method Details

#change_passwordObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/users_controller.rb', line 14

def change_password
  # check if old password correct
  identity = Identity.find_by :code=> $user.code
  if identity.authenticate($xvars["enter"]["epass"])
    identity.password = $xvars["enter"]["npass"]
    identity.password_confirmation = $xvars["enter"]["npass_confirm"]
    identity.save
    ma_log "Password changed"
  else
    ma_log "Unauthorized access"
  end
end

#indexObject



3
4
5
6
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/users_controller.rb', line 3

def index
  @today = Date.today
  @xmains = current_ma_user.xmains.in(status:['R','I']).asc(:created_at)
end

#send_password_resetObject



27
28
29
30
31
32
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/users_controller.rb', line 27

def send_password_reset
  generate_token(:password_reset_token)
  self.password_reset_sent_at = Time.zone.now
  save!
  UserMailer.password_reset(self).deliver
end

#update_userObject

jinda methods



9
10
11
12
13
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/users_controller.rb', line 9

def update_user
  # can't use session, current_ma_user inside jinda methods
  $user.update_attribute :email, $xvars["enter_user"]["user"]["email"]
  $user.update_attribute :image, $xvars["enter_user"]["user"]["image"]
end