dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27119
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13449: Web api, me resource, added function for checking whether current user has an authority granted
------------------------------------------------------------
revno: 13449
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-27 16:10:25 +0100
message:
Web api, me resource, added function for checking whether current user has an authority granted
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2013-12-14 13:17:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2013-12-27 15:10:25 +0000
@@ -64,6 +64,7 @@
import org.hisp.dhis.user.UserSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@@ -252,6 +253,16 @@
userService.updateUser( currentUser );
}
+ @RequestMapping( value = "/authorization/{auth}", produces = { "application/json", "text/*" } )
+ public void hasAuthorization( @PathVariable String auth, HttpServletResponse response ) throws IOException
+ {
+ User currentUser = currentUserService.getCurrentUser();
+
+ boolean hasAuth = currentUser != null && currentUser.getUserCredentials().isAuthorized( auth );
+
+ JacksonUtils.toJson( response.getOutputStream(), hasAuth );
+ }
+
@RequestMapping( value = "/recipients", produces = { "application/json", "text/*" } )
public void recipientsJson( HttpServletResponse response,
@RequestParam( value = "filter" ) String filter ) throws IOException, NotAuthenticatedException, FilterTooShortException