Hi,

I tried the approach you mentioned and changed authenticate the following 
way:


    def authenticate(self, environ, identity):

        ### Addition
        *print >>open('login_succ.txt', 'a'), "\n\nEnviron start ", 
environ, "\n\n"*
        ### Addition end

        login = identity['login']
        user = self.sa_auth.dbsession.query(self.sa_auth.user_class).
filter_by(
            user_name=login
        ).first()

        if not user:
            login = None
        elif not user.validate_password(identity['password']):
            login = None

        if login is None:

            ### Addition
            environ['LOGIN_SUCC'] = 'false'
            ### Addition end

            try:
                from urllib.parse import parse_qs, urlencode
            except ImportError:
                from urlparse import parse_qs
                from urllib import urlencode
            from tg.exceptions import HTTPFound

            params = parse_qs(environ['QUERY_STRING'])
            params.pop('password', None)  # Remove password in case it was 
there
            if user is None:
                params['failure'] = 'user-not-found'
            else:
                params['login'] = identity['login']
                params['failure'] = 'invalid-password'

            # When authentication fails send user to login page.

            environ['repoze.who.application'] = HTTPFound(
                location='?'.join(('%s/login' %(environ['SCRIPT_NAME']), 
urlencode(params, True)))
                #location='?'.join(('/login', urlencode(params, True)))
            )

        ### Addition
        else:
            environ['LOGIN_SUCC'] = 'true'
        print >>open('login_succ.txt', 'a'), "\n\nEnviron end ", environ, 
"\n\n"
        ### Addition end

        return login

It works OK without prefix but with prefix it looks like it does not 
execute authenticate at all (login_succ.txt is empty unlike without prefix).

I hope it helps.

Best Regards

Ervin



On Monday, March 27, 2017 at 2:10:25 PM UTC+2, zov...@gmail.com wrote:
>
> Hi,
>
> I'm having a problem with a site deployed with a prefix. Authorization for 
> the site is enabled but I cannot pass login phase. After I enter username 
> and password i get redirected to: 
>
> https://website/prefix/login_handler?__logins=0&came_from=%2Fprefix%2F
>
> but I get error 404
>
> As a consequence I cannot access any pages that require authorization.
> If I serve the same site with gearbox (without a prefix) I can pass login 
> phase and afterwords access authenticated pages through prefix (for 
> instance https://website/prefix/admin/).
>
> The same goes for logout (error 404 after redirected to 
> https://website/prefix/logout_handler).
>
> Tried to check login handler and logout handler but could not find them in 
> controllers.
>
> The same error happens in TG 2.3.10.
>
> What can be done about it?
>
> With Best Regards
>
> Ervin
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to turbogears+unsubscr...@googlegroups.com.
To post to this group, send email to turbogears@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to