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

Handle deactivated users gracefully from a bank #3631

Closed

Conversation

Josiassejod1
Copy link

@Josiassejod1 Josiassejod1 commented May 31, 2023

Resolves #3587

Description

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation update

How Has This Been Tested?

Screenshots

@Josiassejod1 Josiassejod1 changed the title 3587 deactivated user Handle deactivated users gracefully from a bank May 31, 2023
Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

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

Thanks for the PR - I had some questions/concerns to be addressed.

@@ -99,6 +100,7 @@ def kind
return "admin" if has_role?(Role::ORG_ADMIN, organization)
return "normal" if has_role?(Role::ORG_USER, organization)
return "partner" if has_role?(Role::PARTNER, partner)
return "deactived" if has_role?(Role::DEACTIVATED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't seem like the right way to model the user. We shouldn't be deliberately giving them a deactivated role. If the user has no roles, we should consider that user deactivated and treat them accordingly.

Copy link
Collaborator

@cielf cielf Jun 8, 2023

Choose a reason for hiding this comment

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

Hrm. @dorner -- Here's the thing, though. The bank can deactivate a user and reactivate them. However, there is also a case where someone may go to work for a partner after having worked for a bank (or vice versa), with possible overlap. (pls check the issue ). As things are now (deactivating the user as a user), when the bank deactivates a user, it precludes them working for a partner.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There may well be a way of allowing this situation without using a deactivated role, and if we were to use a deactivated role (which, I admit, is how I thought this would be done, given that we allow reactivation, and that someone might (also) be working with a partner) , it would need to be deactivated in the context of an organization, not just deactivated, imo.

Copy link
Collaborator

@dorner dorner Jun 8, 2023

Choose a reason for hiding this comment

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

Ah - I wasn't aware that the bank needed to be able to reactivate users. If that's the case, then yes an org-level deactivated role probably makes the most sense. However, there might be code lurking around that assumes that if you have any role with an org, you have the most basic one (which is ORG_USER) - so you might need to tweak that assumption. E.g. ensure that if that's the role the user would be given when logging in, the user is instead kicked out.

I'm just a bit concerned about the data - what if someone somehow ends up with both an ORG_USER and a DEACTIVATED role?

Maybe a better approach would be to add a "deactivated" column to the user_roles table and use that. Again, we'd have to ensure the login and permission logic would specifically exclude deactivated roles in 99% of cases. But there's less chance of weird data issues since you are activating and deactivating a specific role. We also get the benefit of (if we need to) in the future allowing any role to be activated and deactivated - e.g. partner users.

Copy link
Collaborator

@dorner dorner Jun 8, 2023

Choose a reason for hiding this comment

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

See RolifyCommunity/rolify#551 - similar idea but here we'd use deactivated instead of deleted. We'd also have to use unscoped when on the page that shows deactivated users.

Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW I have a gut "that sounds right" reaction to the idea of adding the "deactivated" column to the user_roles table.

class DeactiveUsers < ActiveRecord::Migration[7.0]
def change
Users.discarded.each do |user|
user.add_role(:deactivated)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again - here we'd want to just remove all roles rather than add a new one.

@github-actions github-actions bot added the stale label Jul 24, 2023
@cielf
Copy link
Collaborator

cielf commented Jul 29, 2023

Noted that @Josiassejod1 has said (on the issue) that someone can take this off their hands. Not sure if it's a continue with this PR, or a start from scratch situation.

@cielf
Copy link
Collaborator

cielf commented Jan 16, 2024

I think we have a later PR trying to address the same issue -- look into that before working on this one.

@dorner
Copy link
Collaborator

dorner commented Mar 8, 2024

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deactivating users should address the role, rather than deactivating the user per se
3 participants