You need to specify the controller when initializing Auth:

Auth_phanterimages = Auth(db_phanterimages, controller='phanterimages',
                          host_names=myconf.get('host.names'))

If you do that, you also don't have to bother with all of those URL 
settings, as they will automatically be constructed properly based on the 
new controller. Note, you can also specify a custom function via the 
"function" argument.

Anthony

On Friday, June 9, 2017 at 4:22:46 PM UTC-4, Junior Phanter wrote:
>
> Sorry my bad english.
>
> Guys, I need to change the login functions ("default/user") to another 
> controller "phanterimages". I did:
>
>
> on model:
>
> import os
>
> myconf_phanterimages = AppConfig(reload=True)
> db_phanterimages = DAL(myconf_phanterimages.get('db_phanterimages.uri'),
>              pool_size=myconf.get('db_phanterimages.pool_size'),
>              migrate_enabled=myconf.get('db_phanterimages.migrate'),
>              check_reserved=['all'])
>
> Auth_phanterimages = Auth(db_phanterimages, 
> host_names=myconf.get('host.names'))
>
> Auth_phanterimages.define_tables(username=False, signature=False)
> Auth_phanterimages.settings.login_url = URL('phanterimages', 'user', 
> args='login')
> Auth_phanterimages.settings.logged_url = URL('phanterimages', 'user', 
> args='profile')
> Auth_phanterimages.settings.login_next = URL('phanterimages', 'index')
> Auth_phanterimages.settings.logout_next = URL('phanterimages', 'index')
> Auth_phanterimages.settings.profile_next = URL('phanterimages', 'index')
> Auth_phanterimages.settings.register_next = URL('phanterimages', 'user', 
> args='login')
> Auth_phanterimages.settings.retrieve_username_next = URL('phanterimages', 
> 'index')
> Auth_phanterimages.settings.retrieve_password_next = URL('phanterimages', 
> 'index')
> Auth_phanterimages.settings.change_password_next = URL('phanterimages', 
> 'index')
> Auth_phanterimages.settings.request_reset_password_next = 
> URL('phanterimages', 'user', args='login')
> Auth_phanterimages.settings.reset_password_next = URL('phanterimages', 
> 'user', args='login')
> Auth_phanterimages.settings.verify_email_next = URL('phanterimages', 
> 'user', args='login')
>
> on controller:
>
> @Auth_phanterimages.requires_login()
> def index():
>     """um monte de código"""
>     return locals()
>
>
> def user():
>     """
>     exposes:
>     http://..../[app]/default/user/login
>     http://..../[app]/default/user/logout
>     http://..../[app]/default/user/register
>     http://..../[app]/default/user/profile
>     http://..../[app]/default/user/retrieve_password
>     http://..../[app]/default/user/change_password
>     http://..../[app]/default/user/bulk_register
>     use @auth.requires_login()
>         @auth.requires_membership('group name')
>         @auth.requires_permission('read','table name',record_id)
>     to decorate functions that need access control
>     also notice there is http://..../[app]/appadmin/manage/auth to allow 
> administrator to manage users
>     """
>     return dict(form=Auth_phanterimages())
>
> When I log in, everything is fine, when I log out, too ... everything is 
> working in compliance, the problem is when the login fails (wrong password). 
> It 
> is redirected to the controller "default" ("it was in 'phanterimages / 
> user'.").
> Temporarily, until I found another solution. I modified the gluon tools.py 
> file and left it in red:
>
>                     if not user:
>                         self.log_event(self.messages['login_failed_log'],
>                                        request.post_vars)
>                         # invalid login
>                         session.flash = self.messages.invalid_login  #aqui 
> é mensagem do request.flash
>                         callback(onfail, None)
>                         redirect(URL(request.controller, request.function, 
> args=request.args, vars=request.get_vars),
>                             client_side=settings.client_side)
>
> Before it was like this:
>
>                        redirect(self.url(args=request.args, 
> vars=request.get_vars), client_side=settings.client_side) 
>
> Solved my problem, but wanted to know if it's a bug or am I doing 
> something wrong? I searched the internet and found only one user with the 
> same problem in an old post, but the solution that advised him was to go 
> back to the default controller and closed the subject. Someone has a 
> friendlier solution without tampering with gluon source code.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to