navapbc / template-application-rails

Ruby on Rails with USWDS template, including CI/CD, for teams building web applications
Apache License 2.0
2 stars 1 forks source link

Handle errors from auth service #15

Closed rocketnova closed 5 months ago

rocketnova commented 5 months ago

Currently, the auth service (/app-rails/app/services/auth_service.rb) calls create_account() but doesn't handle any errors that the auth service might return (e.g. the email address is already reserved and cannot be used to create a new account).

  def register(email, password, role)
    # @TODO: Handle errors from the auth service, like when the email is already taken
    account = @auth_adapter.create_account(email, password)

    create_db_user(account[:uid], email, account[:provider], role)
  end

This ticket should handle these errors.

ellery-nava commented 5 months ago

@rocketnova - just testing out locally, and it seems like human readable errors are showing up when we run into auth issues, for example:

Screenshot 2024-06-04 at 11 43 08 AM

It seems like catching the errors on the adapter level is sufficient, unless there's another aspect this ticket is supposed to cover?

rocketnova commented 5 months ago

@ellery-nava Thank you for investigating! This looks like an old @TODO that was addressed but wasn't removed. I'll close the ticket.