Sha256: 0e4b9a86b98ed4bccd7551c3f3a4dfbb03be2e460f176a2261b5028492ef0bc4

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

class Roda
  module RodaPlugins
    module Rodauth
      ChangePassword = Feature.define(:change_password) do
        route 'change-password'
        notice_flash 'Your password has been changed'
        error_flash 'There was an error changing your password'
        view 'change-password', 'Change Password'
        after
        additional_form_tags
        button 'Change Password'
        redirect
        require_account

        get_block do |r, auth|
          auth.change_password_view
        end

        post_block do |r, auth|
          if r[auth.password_param] == r[auth.password_confirm_param]
            if auth.password_meets_requirements?(r[auth.password_param].to_s)
              auth.transaction do
                auth.set_password(r[auth.password_param])
                auth.after_change_password
              end
              auth.set_notice_flash auth.change_password_notice_flash
              r.redirect(auth.change_password_redirect)
            else
              @password_error = auth.password_does_not_meet_requirements_message
            end
          else
            @password_error = auth.passwords_do_not_match_message
          end

          auth.set_error_flash auth.change_password_error_flash
          auth.change_password_view
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rodauth-0.10.0 lib/roda/plugins/rodauth/change_password.rb
rodauth-0.9.1 lib/roda/plugins/rodauth/change_password.rb
rodauth-0.9.0 lib/roda/plugins/rodauth/change_password.rb