Sha256: 937dce371edff8c9f4c8f489d5d885846680ca07712ab3dca0e9af238b5b10d8

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

class ProfileController < ApplicationController
  skip_ensure_email_is_verified

  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?

    @update_profile_information_form.update

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

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

    return render turbo_stream: turbo_stream.replace('confirm_user_deletion_modal', partial: 'profile/partials/confirm_user_deletion_modal'), 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

2 entries across 2 versions & 1 rubygems

Version Path
kaze-0.13.0 stubs/hotwire/app/controllers/profile_controller.rb
kaze-0.12.0 stubs/hotwire/app/controllers/profile_controller.rb