Changeset 2186


Ignore:
Timestamp:
Mar 28, 2012, 2:29:09 PM (5 years ago)
Author:
work@…
Message:
  • api methods should not use authentication, only the authenticate method
Location:
trunk/grails-app
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/api/ApiController.groovy

    r2185 r2186  
    4242        def result = [:]
    4343        try {
     44            // TODO - check if token belongs to current user?
    4445            if (!token) {
    4546                // generate a token for this device
    4647                token = new Token(
    47                         deviceID: params.deviceID,
    48                         deviceToken: UUID.randomUUID().toString(),
    49                         sequence: 0
     48                        deviceID    : params.deviceID,
     49                        deviceToken : UUID.randomUUID().toString(),
     50                        user        : authenticationService.getLoggedInUser(),
     51                        sequence    : 0
    5052                ).save(failOnError: true)
    5153            }
     
    8183            response.sendError(401, 'Unauthorized')
    8284        } else {
    83             def user = authenticationService.getLoggedInUser()
     85//            def user = authenticationService.getLoggedInUser()
     86            def user = Token.findByDeviceID(deviceID).user
    8487            def readableStudies = Study.giveReadableStudies(user)
    8588            def studies = []
     
    132135
    133136        // fetch user and study
    134         def user    = authenticationService.getLoggedInUser()
     137//        def user    = authenticationService.getLoggedInUser()
     138        def user    = Token.findByDeviceID(deviceID).user
    135139        def study   = Study.findByStudyUUID(studyToken)
    136140       
     
    195199
    196200        // fetch user and study
    197         def user    = authenticationService.getLoggedInUser()
     201//        def user    = authenticationService.getLoggedInUser()
     202        def user    = Token.findByDeviceID(deviceID).user
    198203        def study   = Study.findByStudyUUID(studyToken)
    199204
  • trunk/grails-app/views/api/index.gsp

    r2184 r2186  
    112112    <h2>example reply</h2>
    113113    <blockquote>
    114         {"count":2,"studies":[{"title":"NuGO PPS human study","description":"Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U.","subjects":11,"species":["Homo sapiens"],"assays":["Mass Sequencing module","SAM module for clinical data","Metabolomics module"],"events":1,"uniqueEvents":["start: 3 days, 22 hours, duration: 8 hours"],"samplingEvents":2,"uniqueSamplingEvents":["start: 0 seconds","start: 4 days, 6 hours"],"eventGroups":1,"uniqueEventGroups":["Root group"],"samples":22},{"title":"NuGO PPS3 mouse study leptin module","description":"C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet.","subjects":80,"species":["Mus musculus"],"assays":["SAM module for clinical data","Metabolomics module"],"events":8,"uniqueEvents":["start: 1 hour, duration: 1 week","start: 1 hour, duration: 4 weeks"],"samplingEvents":2,"uniqueSamplingEvents":["start: 1 week, 1 hour"],"eventGroups":8,"uniqueEventGroups":["10% fat + vehicle for 1 week","10% fat + leptin for 1 week","45% fat + vehicle for 1 week","45% fat + leptin for 1 week","10% fat + vehicle for 4 weeks","10% fat + leptin for 4 weeks","45% fat + vehicle for 4 weeks","45% fat + leptin for 4 weeks"],"samples":80}]}
     114        {"count":2,"studies":[{"token":"f2e085fb-9138-4ebe-a59f-82f1bdc21d7e","title":"NuGO PPS human study","description":"Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U.","subjects":11,"species":["Homo sapiens"],"assays":["Mass Sequencing module","SAM module for clinical data","Metabolomics module"],"events":1,"uniqueEvents":["start: 3 days, 22 hours, duration: 8 hours"],"samplingEvents":2,"uniqueSamplingEvents":["start: 0 seconds","start: 4 days, 6 hours"],"eventGroups":1,"uniqueEventGroups":["Root group"],"samples":22},{"token":"6b7e85b3-b174-492c-ba27-fbfb71ab9b8b","title":"NuGO PPS3 mouse study leptin module","description":"C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet.","subjects":80,"species":["Mus musculus"],"assays":["SAM module for clinical data","Metabolomics module"],"events":8,"uniqueEvents":["start: 1 hour, duration: 1 week","start: 1 hour, duration: 4 weeks"],"samplingEvents":2,"uniqueSamplingEvents":["start: 1 week, 1 hour"],"eventGroups":8,"uniqueEventGroups":["10% fat + vehicle for 1 week","10% fat + leptin for 1 week","45% fat + vehicle for 1 week","45% fat + leptin for 1 week","10% fat + vehicle for 4 weeks","10% fat + leptin for 4 weeks","45% fat + vehicle for 4 weeks","45% fat + leptin for 4 weeks"],"samples":80}]}
    115115    </blockquote>
    116116</p>
Note: See TracChangeset for help on using the changeset viewer.