Since you won't know the user's name until after they log in, you should 
instead do:

auth.settings.login_onaccept = lambda user: user.first_name == 'admin' 
andredirect
(URL('admin', 'system'))

Anthony

On Thursday, May 2, 2013 12:54:34 PM UTC-4, Christian Espinoza wrote:
>
> Hi guys, 
> I'm trying to do a different 'first view' for a admin user, and for this, 
> I was modified my db.py file on this way:
>
> if auth.user.first_name == 'admin':
>     auth.settings.login_next = URL('admin', 'system')
> else:
>     auth.settings.login_next = URL('mainboard', 'index')
>
> But seems that on that point the user doesn't exist yet, how can achieve 
> it?
>
> Thanks in advance.
> Christian.
>
> Error:
> Error ticket for "avl"Ticket ID
>
> 127.0.0.1.2013-05-02.12-47-26.3706ee73-470f-4dd6-bcde-8a400366785c
> <type 'exceptions.AttributeError'> 'NoneType' object has no attribute 
> 'first_name'Versiónweb2py™Version 
> 2.4.6-stable+timestamp.2013.04.21.19.50.11PythonPython 2.7.3: 
> /usr/bin/python (prefix: /usr)Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
>     exec ccode in environment
>   File "/home/www-data/web2py/applications/avl/models/db.py" 
> <https://127.0.0.1/admin/edit/avl/models/db.py>, line 72, in <module>
>     if auth.user.first_name == 'admin':
> AttributeError: 'NoneType' object has no attribute 'first_name'
>
> Error snapshot [image: 
> help]<https://127.0.0.1/admin/default/ticket/avl/127.0.0.1.2013-05-02.12-47-26.3706ee73-470f-4dd6-bcde-8a400366785c#>
>
> <type 'exceptions.AttributeError'>('NoneType' object has no attribute 
> 'first_name')
>
>
>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to