By default it should be

auth.settings.on_failed_authentication = lambda x: redirect(x)


auth.settings.on_failed_authentication can be a function or a url. You
must set it to None somewhere.


On Dec 16, 8:02 pm, NuclearDragon <[email protected]> wrote:
> I was getting an error when attempting to go to a page that requires
> you be logged in, if I was not logged in.
> Traceback:
>
> Traceback (most recent call last):
>   File "/xxx/app/gluon/restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "/xxx/app/applications/init/controllers/xxxxx.py", line 2712,
> in <module>
>   File "/xxx/app/gluon/globals.py", line 96, in <lambda>
>     self._caller = lambda f: f()
>   File "/xxx/app/gluon/tools.py", line 2271, in f
>     '?_next='+urllib.quote(next)
>   File "/xxx/app/gluon/tools.py", line 65, in call_or_redirect
>     redirect(f)
>   File "/xxx/app/gluon/http.py", line 101, in redirect
>     location = location.replace('\r', '%0D').replace('\n', '%0A')
> AttributeError: 'NoneType' object has no attribute 'replace'
>
> So I changed:
>  return call_or_redirect(self.settings.on_failed_authentication,
>                                             self.settings.login_url +
> \
>                                                 '?
> _next='+urllib.quote(next)
>                                             )
> to:
> if self.settings.on_failed_authentication:
>                         return
> call_or_redirect(self.settings.on_failed_authentication,
>                                             self.settings.login_url +
> \
>                                                 '?
> _next='+urllib.quote(next)
>                                             )
>                     else:
>                         return
> call_or_redirect(self.settings.login_url + \
>                                                 '?
> _next='+urllib.quote(next)
>                                            )
>
> Does anyone have any thoughts as to why that was happening? A print
> statement of self.settings.on_failed_authentication at that point
> displays None, which affects the workings of the call_or_redirect
> function.

Reply via email to