Sha256: 475ad890fb157038dc13680ad61b77ad9ca4f39e29dc66637dcc1ec68d347bb2
Contents?: true
Size: 1.9 KB
Versions: 18
Compression:
Stored size: 1.9 KB
Contents
# frozen-string-literal: true module Rodauth Feature.define(:close_account, :CloseAccount) do notice_flash 'Your account has been closed' error_flash 'There was an error closing your account' loaded_templates %w'close-account password-field' view 'close-account', 'Close Account' additional_form_tags button 'Close Account' after before redirect auth_value_method :account_closed_status_value, 3 auth_value_methods( :close_account_requires_password?, :delete_account_on_close? ) auth_methods( :close_account, :delete_account ) route do |r| require_account before_close_account_route r.get do close_account_view end r.post do if !close_account_requires_password? || password_match?(param(password_param)) transaction do before_close_account close_account after_close_account if delete_account_on_close? delete_account end end clear_session set_notice_flash close_account_notice_flash redirect close_account_redirect else set_response_error_status(invalid_password_error_status) set_field_error(password_param, invalid_password_message) set_error_flash close_account_error_flash close_account_view end end end def close_account_requires_password? modifications_require_password? end def close_account unless skip_status_checks? update_account(account_status_column=>account_closed_status_value) end unless account_password_hash_column password_hash_ds.delete end end def delete_account account_ds.delete end def delete_account_on_close? skip_status_checks? end def skip_status_checks? false end end end
Version data entries
18 entries across 18 versions & 1 rubygems