← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20710: Nullpointer check

 

------------------------------------------------------------
revno: 20710
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-10-15 10:07:42 +0200
message:
  Nullpointer check
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java	2015-10-14 09:35:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java	2015-10-15 08:07:42 +0000
@@ -553,13 +553,18 @@
     @Override
     public boolean hasAnyAuthority( String... authorities )
     {
-        UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials();
-
-        for ( String authority : authorities )
+        User user = currentUserService.getCurrentUser();
+        
+        if ( user != null && user.getUserCredentials() != null )
         {
-            if ( userCredentials.isAuthorized( authority ) )
+            UserCredentials userCredentials = user.getUserCredentials();
+    
+            for ( String authority : authorities )
             {
-                return true;
+                if ( userCredentials.isAuthorized( authority ) )
+                {
+                    return true;
+                }
             }
         }