- #COUNT is the number of map requests to allow before exiting and stating a new process
- @@count = COUNT
-
- def authorize_web
- @current_user = User.find_by_token(session[:token])
- end
-
- # The maximum area you're allowed to request, in square degrees
- MAX_REQUEST_AREA = 0.25
-
- def map
- @@count+=1
- response.headers["Content-Type"] = 'text/xml'
- # Figure out the bbox
- bbox = params['bbox']
- unless bbox and bbox.count(',') == 3
- report_error("The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat")
- return
- end
-
- bbox = bbox.split(',')
-
- min_lon = bbox[0].to_f
- min_lat = bbox[1].to_f
- max_lon = bbox[2].to_f
- max_lat = bbox[3].to_f
-
- # check the bbox is sane
- unless min_lon <= max_lon
- report_error("The minimum longitude must be less than the maximum longitude, but it wasn't")
- return
- end
- unless min_lat <= max_lat
- report_error("The minimum latitude must be less than the maximum latitude, but it wasn't")
- return
+ # handle authenticate pass/fail
+ unless current_user
+ # no auth, the user does not exist or the password was wrong
+ response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
+ render :plain => errormessage, :status => :unauthorized
+ return false