Changeset 831
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/RestController.groovy
r829 r831 16 16 */ 17 17 18 import data.*19 18 import dbnp.studycapturing.Study 20 19 import dbnp.studycapturing.Assay 21 20 import grails.converters.* 22 import org.codehaus.groovy.grails.web.json.* 23 21 import nl.metabolomicscentre.dsp.http.BasicAuthentication 24 22 25 23 … … 32 30 /**************************************************/ 33 31 32 def authService 34 33 def beforeInterceptor = [action:this.&auth] 35 34 def credentials 35 def requestUser 36 36 // defined as a regular method so its private 37 37 38 /** 39 * Authorization closure, which is run before executing any of the REST resource actions 40 * It fetches a username/password combination from basic HTTP authentication and checks whether 41 * that is an active (nimble) account 42 * @return 43 */ 38 44 def auth() { 39 credentials = nl.metabolomicscentre.dsp.http.BasicAuthentication.credentialsFromRequest(request) 40 if(false) { 45 credentials = BasicAuthentication.credentialsFromRequest(request) 46 requestUser = authService.authUser(credentials.u,credentials.p) 47 if(!requestUser) { 41 48 response.sendError(403) 42 49 return false 43 50 } 51 else { 52 return true 53 } 44 54 } 45 55 … … 55 65 def getStudies = { 56 66 List studies = [] 57 Study. list().each { study ->67 Study.findAllByOwner(requestUser).each { study -> 58 68 studies.push( [ 'externalStudyID': study.code, 'name':study.title ] ) 59 69 } … … 93 103 List assays = [] 94 104 if( params.externalStudyID ) { 95 println params.moduleURL 96 def study = Study.find( "from Study as s where s.code=?", [params.externalStudyID]) 105 def study = Study.find( "from Study as s where s.owner=? and s.code=?", [requestUser.getId(), params.externalStudyID]) 97 106 if(study) study.assays.each{ assay -> 98 println assay.module.url99 107 if (assay.module.url.equals(params.moduleURL)) { 100 108 def map = ['name':assay.name, 'externalAssayID':assay.externalAssayID]
Note: See TracChangeset
for help on using the changeset viewer.