Class: Faalis::Dashboard::ProfileController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/faalis/dashboard/profile_controller.rb

Instance Method Summary collapse

Instance Method Details

#edit_passwordObject

GET /sites/new



26
27
28
29
# File 'app/controllers/faalis/dashboard/profile_controller.rb', line 26

def edit_password
  @user = ::Faalis::User.find(current_user.id)
  authorize @user
end

#resource_paramsObject



46
47
48
# File 'app/controllers/faalis/dashboard/profile_controller.rb', line 46

def resource_params
  params.require(:user).permit(:password, :current_password, :password_confirmation, :first_name, :last_name, :email)
end

#showObject



3
4
5
6
# File 'app/controllers/faalis/dashboard/profile_controller.rb', line 3

def show
  @user = current_user
  respond_with(@user)
end

#updateObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/faalis/dashboard/profile_controller.rb', line 8

def update
  @user = ::Faalis::User.find(current_user.id)
  authorize @user
  respond_to do |f|
    if @user.update_without_password(resource_params)
      f.js { }
      f.html { }
    else
      @errors = @user.errors
      f.js {render :errors}
      f.html
    end
  end

end

#update_passwordObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/faalis/dashboard/profile_controller.rb', line 31

def update_password
  @user = ::Faalis::User.find(current_user.id)
  authorize @user
  respond_to do |f|
    if @user.update_with_password(resource_params)
      f.js { redirect_to new_user_session_path }
      f.html { redirect_to new_user_session_path }
    else
      @errors = @user.errors
      f.js {render :errors}
      f.html
    end
  end
end