Class: Morpho::PasswordsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/morpho/passwords_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/morpho/passwords_controller.rb', line 6

def create
  if user
    user.deliver_reset_password_instructions!
    flash.now[:notice] = I18n.t('morpho.messages.passwords.create.success')
    render :new
  else
    flash.now[:error] = I18n.t('morpho.messages.passwords.create.failure')
    render :new
  end
end

#editObject



17
18
19
20
21
22
# File 'app/controllers/morpho/passwords_controller.rb', line 17

def edit
  unless user
    flash.now[:error] = I18n.t('morpho.messages.passwords.edit.failure')
    render :new
  end
end

#updateObject



24
25
26
27
28
29
30
31
32
# File 'app/controllers/morpho/passwords_controller.rb', line 24

def update
  if user.update_attributes(password_params)
    user.change_password!(password_params[:password])
    redirect_to , success: I18n.t('morpho.messages.passwords.update.success')
  else
    flash.now[:error] = I18n.t('morpho.messages.passwords.update.failure')
    render :edit
  end
end