Skip to content

Commit

Permalink
Add default organization for default role login
Browse files Browse the repository at this point in the history
  • Loading branch information
yamelsenih committed Oct 29, 2021
1 parent b4a6daa commit ad3e29c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/spin/base/util/SessionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public static int getDefaultOrganizationId(int roleId, int userId) {
+ "INNER JOIN AD_Client c ON(c.AD_Client_ID = r.AD_Client_ID) "
+ "INNER JOIN AD_Org o ON(c.AD_Client_ID=o.AD_Client_ID OR o.AD_Org_ID=0) "
+ "WHERE r.AD_Role_ID=? "
+ " AND o.IsActive='Y' AND o.IsSummary='N' AND o.AD_Org_ID <> 0"
+ " AND o.IsActive='Y' AND o.IsSummary='N'"
+ " AND (r.IsAccessAllOrgs='Y' "
+ "OR (r.IsUseUserOrgAccess='N' AND EXISTS(SELECT 1 FROM AD_Role_OrgAccess ra WHERE ra.AD_Org_ID = o.AD_Org_ID AND ra.AD_Role_ID = r.AD_Role_ID AND ra.IsActive='Y')) "
+ "OR (r.IsUseUserOrgAccess='Y' AND EXISTS(SELECT 1 FROM AD_User_OrgAccess ua WHERE ua.AD_Org_ID = o.AD_Org_ID AND ua.AD_User_ID = ? AND ua.IsActive='Y'))"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ private Session.Builder createSession(LoginRequest request, boolean isDefaultRol
// Organization
if(organizationId < 0) {
organizationId = SessionManager.getDefaultOrganizationId(roleId, userId);
if(organizationId < 0) {
organizationId = 0;
}
}
warehouseId = DB.getSQLValue(null, "SELECT M_Warehouse_ID FROM M_Warehouse WHERE IsActive = 'Y' AND AD_Org_ID = ?", organizationId);
} else {
Expand Down

0 comments on commit ad3e29c

Please sign in to comment.