Hi Marlysson, thanks so much for the links you shared, they are very 
helpful. I actually read your previous post to another user suggesting to 
look into tools.py, i did, now i understand better after looking into the 
web2py.readthedocs API reference. 

Thanks much Anthony, Marlysson.

On Monday, April 10, 2017 at 11:31:00 PM UTC+8, Marlysson Silva wrote:
>
> There are this places..
>
> https://github.com/web2py/web2py/blob/master/gluon/tools.py#L1487
>
>
> http://web2py.readthedocs.io/en/latest/tools.html?highlight=auth#gluon.tools.Auth
>
> Em domingo, 9 de abril de 2017 13:16:31 UTC-3, Rudy escreveu:
>>
>> Sorry Anthony, i just checked, your suggestion works when i have 
>> accounting and ticketing systems sharing the same auth's tables, basically 
>> it just uses the 'user' action under accounting controller to do all the 
>> authentication.
>>
>> Appreciate if you can provide pointer for more info about Auth() 
>> arguments. Thanks!
>>
>> On Monday, April 10, 2017 at 12:09:44 AM UTC+8, Rudy wrote:
>>>
>>> Hi Anthony,
>>>
>>> Thanks again, it works. Now it leads to another question - my 
>>> application has accounting system and ticketing system sharing the same 
>>> auth's tables. The 2 systems are in different controllers namely accounting 
>>> & ticketing. All my accounting view htmls extend layout_accounting.html, 
>>> all the ticketing view htmls extend layout_ticketing.html, inside these 
>>> layout files, they include their corresponding menu i.e. 
>>> response.menu_accounting, response.menu_ticketing. If i use your suggestion 
>>> below, it will work well for accounting but not for ticketing under the 
>>> same application. How should I address it?
>>>
>>> Could you tell me where I find the definition/documentation of Auth()'s 
>>> arguments? What does function='user' do here? Many thanks in advance!
>>>
>>> On Sunday, April 9, 2017 at 11:48:43 PM UTC+8, Anthony wrote:
>>>>
>>>> auth = Auth(..., controller='accounting', function='user')
>>>>
>>>> Anthony
>>>>
>>>> On Sunday, April 9, 2017 at 11:13:33 AM UTC-4, Rudy wrote:
>>>>>
>>>>> Hi there,
>>>>>
>>>>> I have created an accounting application, say the landing page is 
>>>>> http://localhost:8000/tests/accounting/index. I need to change the 
>>>>> link under "LOG IN" dropdown menu on top right corner to 
>>>>> http://...../tests/accounting/user/login instead of using 
>>>>> http://...../tests/default/user/login. I thought it was pretty common & 
>>>>> simple, after I read a few posts on webypy-users group, I still don't 
>>>>> know 
>>>>> how to change it. Below is what I have tried:
>>>>>
>>>>> 1) Found below suggestion from Massimo, i commented out {{='auth' in 
>>>>> globals() and auth.navbar('Welcome', mode='dropdown') or ''}}, and added 
>>>>> below in layout.html
>>>>>           {{if auth.user:}}
>>>>>               <a href="{{=URL('accounting','user/logout')}}">Logout</a>
>>>>>           {{else:}}
>>>>>               <a href="{{=URL('accounting','user/login')}}">Login</a>
>>>>>               <a 
>>>>> href="{{=URL('accounting','user/register')}}">Register</a>
>>>>>               <a 
>>>>> href="{{=URL('accounting','user/retrieve_password')}}">Lost Password</a>
>>>>>           {{pass}}
>>>>>     By doing above, I went 
>>>>> to http://...../tests/accounting/user/login form, once I filled the form 
>>>>> and clicked the blue "LOG IN" button (the authentication went through), 
>>>>> it 
>>>>> redirected to http://..../tests/default/login#, same issue happened when 
>>>>> I 
>>>>> logged out. How can I tell web2py where the next_url is? Or should I take 
>>>>> this approach at all to address my original question? If this is the way 
>>>>> to 
>>>>> do it, any easy way to make it as dropdown menu instead of just links?
>>>>>
>>>>> 2) Then i tried to understand better how auth.navbar works by looking 
>>>>> into tools.py under gluon. I found navbar takes an argument action, i 
>>>>> modified it in layout.html to {{='auth' in globals() and 
>>>>> auth.navbar('Welcome', action='/tests/accounting/user', mode='dropdown') 
>>>>> or 
>>>>> ''}}.  I went to the correct form when I clicked the LOG IN link, the 
>>>>> redirect went to the correct controller and action, but only when I 
>>>>> logged 
>>>>> out, the var _next pointed to and redirected to the default controller 
>>>>> again - ?_next=/tests/default/index. How do i fix it? What does the 
>>>>> argument "referred_action" do?
>>>>>
>>>>> 3) I mixed point 1 above and Anthony suggestion - added point 1 above 
>>>>> in layout.html, so that it went to correct login form, then I added below 
>>>>> in tests/accounting/user action:
>>>>>     form = auth()
>>>>>     if request.args(0) == 'login':
>>>>>         form['_action'] = URL(args=request.args)
>>>>>   The behaviour went exactly like point 1 above
>>>>>
>>>>> I thought most applications would change this authentication urls, 
>>>>> there must be a better way to configure it, I already spent the weekend 
>>>>> on 
>>>>> it. Any pointers are much appreciated.
>>>>>
>>>>

-- 
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