Skip to content

Commit

Permalink
Issue #LR-676 merge: User Delete functionality (#1222)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayaprakash8887 authored Oct 30, 2023
1 parent 52e0dc9 commit 300d864
Show file tree
Hide file tree
Showing 33 changed files with 1,468 additions and 583 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.sunbird.request.Request;
import play.mvc.Http;
import play.mvc.Result;
import util.Attrs;
import util.Common;

public class UserStatusController extends BaseController {

Expand Down Expand Up @@ -40,4 +42,17 @@ public CompletionStage<Result> unblockUser(Http.Request httpRequest) {
},
httpRequest);
}

public CompletionStage<Result> deleteUser(Http.Request httpRequest) {
return handleRequest(
userStatusActor,
ActorOperations.DELETE_USER.getValue(),
httpRequest.body().asJson(),
request -> {
new UserStatusRequestValidator()
.validateUserId(Common.getFromRequest(httpRequest, Attrs.USER_ID));
return null;
},
httpRequest);
}
}
4 changes: 3 additions & 1 deletion controller/app/util/ACTORS.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public enum ACTORS {
USER_TNC_ACTOR(UserTnCActor.class, "user_tnc_actor"),
USER_TYPE_ACTOR(UserTypeActor.class, "user_type_actor"),
USER_UPDATE_ACTOR(UserUpdateActor.class, "user_update_actor"),
BACKGROUND_JOB_MANAGER_ACTOR(BackgroundJobManager.class, "background_job_manager_actor");
BACKGROUND_JOB_MANAGER_ACTOR(BackgroundJobManager.class, "background_job_manager_actor"),
USER_DELETION_BACKGROUND_JOB_ACTOR(
UserDeletionBackgroundJobActor.class, "user_deletion_background_job_actor");

ACTORS(Class clazz, String name) {
actorClass = clazz;
Expand Down
10 changes: 10 additions & 0 deletions controller/conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ akka {
throughput = 1
}
deployment {
"/user_deletion_background_job_actor"
{
router = smallest-mailbox-pool
nr-of-instances = 5
dispatcher = brr-usr-dispatcher
}
"/user_deletion_background_job_actor/*"
{
dispatcher = akka.actor.brr-usr-dispatcher
}
"/background_job_manager_actor"
{
router = smallest-mailbox-pool
Expand Down
3 changes: 3 additions & 0 deletions controller/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,6 @@ GET /v1/system/settings/get/:field @controllers.systemsettings.Syst
GET /v1/system/settings/list @controllers.systemsettings.SystemSettingsController.getAllSystemSettings(request: play.mvc.Http.Request)
POST /v1/system/settings/set @controllers.systemsettings.SystemSettingsController.setSystemSetting(request: play.mvc.Http.Request)


POST /v1/user/delete @controllers.usermanagement.UserStatusController.deleteUser(request: play.mvc.Http.Request)

Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ public enum ResponseCode {
invalidTenantSecurityLevelLower(
ResponseMessage.Key.INVALID_TENANT_SECURITY_LEVEL_LOWER,
ResponseMessage.Message.INVALID_TENANT_SECURITY_LEVEL_LOWER),
cannotDeleteUser(
ResponseMessage.Key.CANNOT_DELETE_USER, ResponseMessage.Message.CANNOT_DELETE_USER),
OK(200),
SUCCESS(200),
CLIENT_ERROR(400),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ interface Message {
"Default data security policy settings is missing for the job: {0}";
String INVALID_TENANT_SECURITY_LEVEL_LOWER =
"Tenant level's security {0} cannot be lower than system level's security {1}. Please provide a valid data security level.";
String CANNOT_DELETE_USER = "User is restricted from deleting account based on roles!";
}

interface Key {
Expand Down Expand Up @@ -206,5 +207,6 @@ interface Key {
String INVALID_SECURITY_LEVEL_LOWER = "0080";
String MISSING_DEFAULT_SECURITY_LEVEL = "0081";
String INVALID_TENANT_SECURITY_LEVEL_LOWER = "0082";
String CANNOT_DELETE_USER = "0083";
}
}
19 changes: 19 additions & 0 deletions core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public final class JsonKey {
public static final String IS_SELF_DECLARATION = "isSelfDeclaration";
public static final String IS_SYSTEM_UPLOAD = "isSystemUpload";
public static final String IS_AUTH_REQ = "isAuthReq";
public static final String IS_BLOCKED = "isBlocked";
public static final String IS_DELETED = "isDeleted";
public static final String JOB_PROFILE = "jobProfile";
public static final String LANGUAGE = "language";
Expand Down Expand Up @@ -296,6 +297,7 @@ public final class JsonKey {
public static final String URL_ACTION = "url_action";
public static final String URL_ACTION_ID = "url_action_ids";
public static final String USER = "user";
public static final String USER_OWNERSHIP_TRANSFER = "user_ownership_transfer";
public static final String USER_ACTION_ROLE = "user_action_role";
public static final String USER_DB = "user_db";
public static final String USER_ID = "userId";
Expand Down Expand Up @@ -591,6 +593,8 @@ public final class JsonKey {
public static final String STATE_ID = "stateId";
public static final String BLOCK_USER = "BlockUser";
public static final String UNBLOCK_USER = "UnblockUser";
public static final String DELETE_USER = "DeleteUser";
public static final String DELETE_USER_STATUS = "DeleteUserStatus";
public static final String ROLE_OPERATION = "roleOperation";
public static final String SCOPE_STR = "scopeString";
public static final String SUNBIRD_SSO_LB_IP = "sunbird_sso_lb_ip";
Expand Down Expand Up @@ -644,6 +648,7 @@ public final class JsonKey {
public static final String DATA_SECURITY_POLICY = "dataSecurityPolicy";
public static final String JOB = "job";
public static final String USER_PRIVATE_FIELDS = "userPrivateFields";

//Release 5.4.0 LR-102
public static final String SUNBIRD_KEYSPACE = "sunbird_keyspace";
public static final String ES_LOCATION_INDEX = "es_location_index";
Expand All @@ -652,5 +657,19 @@ public final class JsonKey {
public static final String ES_USER_INDEX_ALIAS = "user_index_alias";
public static final String ES_ORG_INDEX_INDEX = "org_index_alias";

public static final String USER_DELETION_STATUS = "user_deletion_status";
public static final String CREDENTIALS_STATUS = "keycloakCredentials";
public static final String USER_LOOK_UP_STATUS = "userLookUpTable";
public static final String USER_EXTERNAL_ID_STATUS = "userExternalIdTable";
public static final String USERS = "users";
public static final String USER_TABLE_STATUS = "userTable";
public static final String SUGGESTED_USERS = "suggested_users";
public static final String DELETE_USER_ACTON = "delete-user";
public static final String OBJECT = "object";
public static final String EDATA = "eData";
public static final String MANAGED_USERS = "managed_users";
public static final String USER_DELETION_TOPIC = "user-deletion-broadcast-topic";
public static final String USER_DELETION_ROLES = "user-deletion-roles";

private JsonKey() {}
}
Loading

0 comments on commit 300d864

Please sign in to comment.