On Thu, Jan 25, 2018 at 1:13 AM, Craig Russell <[email protected]> wrote:
>
>> On Jan 24, 2018, at 6:38 PM, Sam Ruby <[email protected]> wrote:
>>
>>> 2. I cannot get the redirection to work. If the user enters 
>>> whimsy.apache.org/project/icla?token=1 and file /srv/icla/1.json is in 
>>> phase discuss, I'd like to "forward" that request to
>>> whimsy.apache.org/project/icla/discuss?token=1 and similarly, if the user 
>>> enters whimsy.apache.org/project/icla?token=2 and file /srv/icla/2.json is 
>>> in phase discuss, I'd like to "forward" that request to
>>> whimsy.apache.org/project/icla/vote?token=2
>>
>> I see redirect calls within get '/', but '1.json' above won't match
>> that.  You would need to code a get clause that matches that pattern.
>
> get '/' do should match whimsy.apache.org/project/icla 
> <http://whimsy.apache.org/project/icla> Right?

Right.  My apologies, I read too fast.

> This get is supposed to match whimsy.local/project/icla?token=1 and 
> whimsy.local/project/icla?token=2
>
> get '/' do
>   @token = params['token']
>   @progress = loadProgress(@token) if @token
>   @phase = @progress[:phase] if @progress
>   if @phase == 'discuss'
>     redirect to("/discuss?token=" + @token)
>   elsif @phase == 'vote'
>     redirect to("/vote?token=" + @token)
>   else
>     redirect to("/invite")
>   end
> end
>
> And then it is supposed to redirect to 
> whimsy.local/project/icla/discuss?token=1
> But instead it redirects to http://whimsy.local/project/icla/invite
>
> And  whimsy.local/project/icla?token=2 is supposed to redirect to 
> whimsy.local/project/icla/vote?token=2
> But it also redirects to http://whimsy.local/project/icla/invite
>>
>> As for "?token=2" with no path, get '/' does match that, and appears to work:
>>
>> $ curl --head --user rubys https://whimsy.apache.org/project/icla?token=2
>> Enter host password for user 'rubys':
>> HTTP/1.1 303 See Other
>> Date: Thu, 25 Jan 2018 02:24:35 GMT
>> Server: Apache/2.4.18 (Ubuntu)
>> X-XSS-Protection: 1; mode=block
>> X-Content-Type-Options: nosniff
>> X-Frame-Options: SAMEORIGIN
>> X-Powered-By: Phusion Passenger 5.1.12
>> Location: https://whimsy.apache.org/project/icla/invite
>> Status: 303 See Other
>> Content-Type: text/html;charset=utf-8
>
> This was supposed to redirect to Location: 
> https://whimsy.apache.org/project/icla/vote?token=2

Looks to me like the redirect worked, but the if check did not do what
you expected.  @phase is neither 'discuss' nor 'vote'.  Just a guess,
but perhaps what you want is @progress['phase'] as this data was read
from JSON so the hash indexes are likely to be strings.

If this is not the problem, consider adding a line like the following
and then trying the curl command I mentioned above to see what is
going on:

response.headers['debug-progress'] = @progress.inspect

- Sam Ruby


>> What problem are you seeing?
>
>
> Craig L Russell
> Secretary, Apache Software Foundation
> [email protected] http://db.apache.org/jdo
>

Reply via email to