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



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

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



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

def index
  @today  = Time.zone.today
  @xmains = current_ma_user.xmains.in(status: %w[R I]).asc(:created_at)
end

#send_password_resetObject



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

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



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

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