-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(user): add support to delete user #3374
Conversation
4f70c35
to
1758e55
Compare
@@ -104,4 +104,18 @@ impl DashboardMetadata { | |||
) | |||
.await | |||
} | |||
|
|||
pub async fn delete_user_scoped_dashboard_metadata( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to delete_user_scoped_dashboard_metadata_by_merchant_id
Self::UserNotExist => AER::BadRequest(ApiError::new( | ||
sub_code, | ||
30, | ||
"User does not exist in records", | ||
None, | ||
)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
crates/router/src/core/user.rs
Outdated
.find(|&role| role.merchant_id == user_from_token.merchant_id.as_str()) | ||
{ | ||
Some(user_role) => { | ||
let _ = can_delete_user_role(&user_role.role_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error handling ?
crates/router/src/utils/user.rs
Outdated
consts::user_role::ROLE_ID_ORGANIZATION_ADMIN | ||
| consts::user_role::ROLE_ID_INTERNAL_ADMIN | ||
| consts::user_role::ROLE_ID_INTERNAL_VIEW_ONLY_USER | ||
| consts::user_role::INTERNAL_USER_MERCHANT_ID => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
Description indicates you're deleting user from org but looks like you're deleting user from merchant account. |
crates/router/src/core/user_role.rs
Outdated
.find(|&role| role.merchant_id == user_from_token.merchant_id.as_str()) | ||
{ | ||
Some(user_role) => { | ||
utils::user::validate_deletion_permission_for_role_id(&user_role.role_id)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user_role
util instead of user
util
crates/router/src/utils/user.rs
Outdated
pub fn validate_deletion_permission_for_role_id(role_id: &str) -> UserResult<()> { | ||
match role_id { | ||
consts::user_role::ROLE_ID_ORGANIZATION_ADMIN | ||
| consts::user_role::ROLE_ID_INTERNAL_ADMIN | ||
| consts::user_role::ROLE_ID_INTERNAL_VIEW_ONLY_USER => { | ||
Err(UserErrors::InvalidDeleteOperation.into()) | ||
.attach_printable("Deletion not allowed for users with specific role id") | ||
} | ||
_ => Ok(()), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this property of predefined permission.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test locally.
@@ -176,6 +176,7 @@ impl From<Flow> for ApiIdentifier { | |||
| Flow::ForgotPassword | |||
| Flow::ResetPassword | |||
| Flow::InviteUser | |||
| Flow::DeleteUser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this in UserRoles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Type of Change
Description
Add add new endpoint
/user/user/delete
that deletes the user present in the merchant accountHere we have two scenarios
Additional Changes
Motivation and Context
Currently there is no endpoint to remove the invited users
How did you test it?
Use the following curl to invite users:
Use the following curl to delete invited user:
Cases to handle:
Checklist
cargo +nightly fmt --all
cargo clippy