Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@enescakir
Copy link
Member

@enescakir enescakir commented Oct 24, 2025

!! It doesn't have tests yet !!

  • Combine account password change and login pages
    Previously, we had separate pages for changing passwords and logging in,
    which was unnecessary. This change combines them into a single unified
    page for a simpler user experience.

    I plan to add account renaming functionality to this page in a future
    commit.

  • Add path helper to account model

  • Do not check authorization for renaming if it's passed as nil explicitly
    We don't need to check authorization for all cases such as renaming
    accounts.

  • Skip storing audit logs when no project context is available
    Some actions, such as renaming accounts, call the audit_log helper
    without a project context. In these cases, there's no relevant project
    information to log, so we now skip storing audit logs when the project
    context is missing.

  • Add account renaming functionality
    Thanks to @jeremyevans's renaming helpers, it was straightforward to
    implement.

account_rename

@enescakir enescakir self-assigned this Oct 24, 2025
@enescakir
Copy link
Member Author

Because of the first commit, authentication tests are failing with the following exception. @jeremyevans, how can I fix this issue? Architecturally, is the first commit incorrect?

8) Clover auth authenticated can change password when password entry is not required
     Failure/Error: Clover.app.call(env)

     NoMethodError:
       undefined method 'params' for #<Clover::RodaRequest:0x000000012a912eb0>
     # ./coverage/views/components-rodauth-login_field.erb.rb:14:in 'Tilt::CompiledTemplates#__tilt_2640'
     # ./coverage/views/account-settings.erb.rb:25:in 'block in Tilt::CompiledTemplates#__tilt_2640'
     # ./coverage/views/account-settings.erb.rb:19:in 'Tilt::CompiledTemplates#__tilt_2640'
     # ./routes/account.rb:15:in 'block (3 levels) in <class:Clover>'
     # ./routes/account.rb:11:in 'block (2 levels) in <class:Clover>'
     # ./routes/account.rb:5:in 'block in <class:Clover>'
     # ./clover.rb:1019:in 'block in <class:Clover>'
     # ./spec/routes/spec_helper.rb:64:in 'block (3 levels) in <top (required)>'
     # ./spec/routes/spec_helper.rb:63:in 'block (2 levels) in <top (required)>'
     # ./spec/routes/web/auth_spec.rb:447:in 'block (4 levels) in <top (required)>'
     # ./spec/spec_helper.rb:60:in 'block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:59:in 'block (2 levels) in <top (required)>'

@enescakir enescakir requested a review from jeremyevans October 24, 2025 13:56
@jeremyevans
Copy link
Contributor

Because of the first commit, authentication tests are failing with the following exception. @jeremyevans, how can I fix this issue? Architecturally, is the first commit incorrect?

For catch use of untype-checked parameters in our templates, we undefine params during non-frozen testing. This breaks rodauth.params. This isn't usually a problem, because we don't undefine it until after r.rodauth. However, you are now loading a rodauth-specific template after r.rodauth.

To workaround this issue, you can change rodauth.param('login') to typecast_params.str('login') in the login_field.erb template (technically, rodauth.param returns an empty string instead of nil if the parameter is not submitted, but that shouldn't matter in this case).

Copy link
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't object to the combining of the change login and change login pages, but I don't think it makes things simpler. Changing login and changing password are generally done for different reasons, so putting them on the same page doesn't result in a simpler user experience to me. It also seems unrelated to account renaming. However, it doesn't cause harm.

clover.rb Outdated
].each { path(it, class_name: true, &under_project_path) }

path("Project", class_name: true, &:path)
path("Account", class_name: true, &:path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering this is static and not dynamic, I would not recommend a model method. Maybe:

Suggested change
path("Account", class_name: true, &:path)
path("Account", class_name: true) { |_| '/account' }

model/account.rb Outdated
Comment on lines 18 to 21
def path
"/account"
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def path
"/account"
end

We don't need to check authorization for all cases such as renaming
accounts.
Some actions, such as renaming accounts, call the audit_log helper
without a project context. In these cases, there's no relevant project
information to log, so we now skip storing audit logs when the project
context is missing.
We only use template_prefix in a single place, and the show_object
helper already accepts a template. This change makes them consistent and
also allows using the helper for resources without a show view.
It allows to use the rename route helper other than in settings page.
We allow spaces in account names and not allow leading spaces.

We should not allow trailing spaces too.
Thanks to @jeremyevans's renaming helpers, it was straightforward to
implement.
@enescakir enescakir force-pushed the enes/allow-account-rename branch from d789fe8 to 412a921 Compare October 31, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants