Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking pet when viewing adoption applications as adopter fosterer leads to unauthorized error #1056

Open
coalest opened this issue Oct 10, 2024 · 8 comments
Assignees
Labels
bug 🐞 Something isn't working Stale

Comments

@coalest
Copy link
Contributor

coalest commented Oct 10, 2024

Reproduction steps:

  1. Log in as an adopter, eg. [email protected]:123456
  2. Go to the Adoption Applicationspage
  3. Click on a pet's name.
  4. See the error message like screenshot below:
    Screenshot from 2024-10-10 20-27-17

Expected behavior:

In theory I have already put in an application to adopt these pets, so I would expect to be directed to a page with information about that pet (either generic information or information on the application I made).

Actual behavior:

I see an error message flash that says "You are not authorized to perform this action."
In the logs, I see a request was sent to GET /alta/adoptable_pets/1 failed the policy check and resulted in a 302 redirect.
I believe because this part of the expression returns false as the pet does have a match (the current user).

@kasugaijin kasugaijin added the bug 🐞 Something isn't working label Oct 11, 2024
@princekumarg12
Copy link

Hi,
I would like to take on the task regarding the authorization issue with the adoption application page. I believe I can help identify and resolve the underlying policy check problem.

Please let me know if I can be assigned to this task.

@kasugaijin
Copy link
Collaborator

@princekumarg12 all yours!

@princekumarg12
Copy link

@kasugaijin i found this while debugging

There are two reasons for this bug:

  1. user.staff_account is nil, which causes authorization to be denied.
    See the screenshot for reference.
    Screenshot from 2024-10-13 00-28-54

  2. The user does not have permission to "manage_pets."

@kasugaijin
Copy link
Collaborator

kasugaijin commented Oct 12, 2024

Ah good catch! So we have this PR #1039 to remove the StaffAccount and replace it with Person model. Can you please check out that branch and see if the bug still happens on that branch? It might not be a bug in that branch.

@princekumarg12
Copy link

I checked out the branch 1034-replace-staffaccount and found that the issue still persists.

@kasugaijin
Copy link
Collaborator

Ah ok thank you! I think it would make sense to hang on until that branch #1039 is merged because we are changing the architecture around a bit, and I think that would impact this fix.

@kasugaijin
Copy link
Collaborator

FYI @princekumarg12 that branch mentioned above is now merged. Are you interested in pursuing this now?

Copy link

This issue is marked as stale due to no activity within 30 days. If no further activity is detected within 7 days, it will be unassigned.

@github-actions github-actions bot added the Stale label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

3 participants