Skip to content

Commit

Permalink
Merge branch 'beta' of https://github.com/ekstep/sunbird-mw into beta
Browse files Browse the repository at this point in the history
issue #1 fix:merger with beta-dev
  • Loading branch information
root authored and root committed Jul 10, 2017
2 parents 88d8ae0 + c90c5bc commit 7878148
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private void initializeRouterMap() {
routerMap.put(ActorOperations.CHANGE_PASSWORD.getValue(), userManagementRouter);
routerMap.put(ActorOperations.GET_PROFILE.getValue(), userManagementRouter);
routerMap.put(ActorOperations.GET_ROLES.getValue(), userManagementRouter);
routerMap.put(ActorOperations.VERIFY_USER_EXISTENCE.getValue(), userManagementRouter);

routerMap.put(ActorOperations.CREATE_PAGE.getValue(), pageManagementRouter);
routerMap.put(ActorOperations.UPDATE_PAGE.getValue(), pageManagementRouter);
Expand Down
27 changes: 25 additions & 2 deletions src/main/java/org/sunbird/learner/actors/UserManagementActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public void onReceive(Object message) throws Throwable {
joinUserOrganisation(actorMessage);
}else if (actorMessage.getOperation().equalsIgnoreCase(ActorOperations.APPROVE_USER_ORGANISATION.getValue())){
approveUserOrg(actorMessage);
}else {
}else if (actorMessage.getOperation().equalsIgnoreCase(ActorOperations.VERIFY_USER_EXISTENCE.getValue())){
verifyUser(actorMessage);
}else {
logger.info("UNSUPPORTED OPERATION");
ProjectCommonException exception = new ProjectCommonException(ResponseCode.invalidOperationName.getErrorCode(), ResponseCode.invalidOperationName.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode());
sender().tell(exception, self());
Expand All @@ -84,6 +86,23 @@ public void onReceive(Object message) throws Throwable {
}
}

@SuppressWarnings("unchecked")
private void verifyUser(Request actorMessage) {
Util.DbInfo usrDbInfo = Util.dbInfoMap.get(JsonKey.USER_DB);
Response response = new Response();
Map<String , Object> userMap=(Map<String, Object>) actorMessage.getRequest().get(JsonKey.USER);
if(null != userMap.get(JsonKey.LOGIN_ID)){
String loginId = (String)userMap.get(JsonKey.LOGIN_ID);
Response resultFrEmail = cassandraOperation.getRecordsByProperty(usrDbInfo.getKeySpace(),usrDbInfo.getTableName(),JsonKey.LOGIN_ID,loginId);
if(!((List<Map<String,Object>>)resultFrEmail.get(JsonKey.RESPONSE)).isEmpty()){
response.put(JsonKey.RESPONSE, JsonKey.USER_FOUND);
}else{
response.put(JsonKey.RESPONSE, JsonKey.USER_NOT_FOUND);
}
sender().tell(response, self());
}
}

/**
* Method to get the user profile .
* @param actorMessage Request
Expand Down Expand Up @@ -549,7 +568,11 @@ private void createUser(Request actorMessage){
userMap.put(JsonKey.USER_ID,OneWayHashing.encryptVal((String)userMap.get(JsonKey.USERNAME)));
userMap.put(JsonKey.ID,OneWayHashing.encryptVal((String)userMap.get(JsonKey.USERNAME)));
}
userMap.put(JsonKey.LOGIN_ID, ((String)userMap.get(JsonKey.USERNAME)+"@"+(String)userMap.get(JsonKey.PROVIDER)));
if(!ProjectUtil.isStringNullOREmpty((String)userMap.get(JsonKey.PROVIDER))){
userMap.put(JsonKey.LOGIN_ID, ((String)userMap.get(JsonKey.USERNAME)+"@"+(String)userMap.get(JsonKey.PROVIDER)));
}else{
userMap.put(JsonKey.LOGIN_ID,userMap.get(JsonKey.USERNAME));
}
userMap.put(JsonKey.CREATED_DATE, ProjectUtil.getFormattedDate());
userMap.put(JsonKey.STATUS, ProjectUtil.Status.ACTIVE.getValue());
if(!ProjectUtil.isStringNullOREmpty((String)userMap.get(JsonKey.PASSWORD))){
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/cassandra.cql
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,6 @@ CREATE TABLE IF NOT EXISTS sunbird.org_type(id text, name text, PRIMARY KEY (id)
DROP INDEX sunbird.inx_org_status;
ALTER TABLE sunbird.organisation DROP status ;
ALTER TABLE sunbird.organisation ADD status text;
CREATE INDEX inx_org_status ON sunbird.organisation (status);
CREATE INDEX inx_org_status ON sunbird.organisation (status);

CREATE INDEX inx_u_loginId ON sunbird.user(loginId);

0 comments on commit 7878148

Please sign in to comment.