Sha256: fa1bbe4164320f2d0af08c9d38a3df8ecb44bcf20b641eb4a53acda5f51f9c56

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

class ProfileController < ApplicationController
  def edit
    @update_profile_information_form = UpdateProfileInformationForm.new(name: Current.auth.user.name, email: Current.auth.user.email)
    @update_password_form = UpdatePasswordForm.new
    @delete_user_form = DeleteUserForm.new

    render 'profile/edit'
  end

  def update
    @update_profile_information_form = UpdateProfileInformationForm.new params.permit(:name, :email)

    return render partial: 'profile/partials/update_profile_information_form', status: :unprocessable_entity if @update_profile_information_form.invalid?

    Current.auth.user.update(name: @update_profile_information_form.name, email: @update_profile_information_form.email)

    redirect_to profile_edit_path, flash: { status: 'profile-updated' }
  end

  def destroy
    @delete_user_form = DeleteUserForm.new params.permit(:password)

    return render partial: 'profile/partials/delete_user_form', status: :unprocessable_entity if @delete_user_form.invalid?

    user = Current.auth.user

    Current.auth.logout

    user.delete

    reset_session

    redirect_to '/'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kaze-0.8.0 stubs/hotwire/app/controllers/profile_controller.rb
kaze-0.7.0 stubs/hotwire/app/controllers/profile_controller.rb
kaze-0.6.0 stubs/hotwire/app/controllers/profile_controller.rb