Removing need for first and last name in auth

ยอดดู 561 ครั้ง
ข้ามไปที่ข้อความที่ยังไม่อ่านรายการแรก

HittingSmoke

ยังไม่อ่าน,
29 ม.ค. 2555 19:36:0729/1/55
ถึง web2py-users
I'd like to use auth with only a username instead of first and last
name. I defined my own tables without a first and last name but it
still causes issues throughout the app.

For instance, when I try to use appadmin to add a user to a new auth
group I get an error (<type 'exceptions.KeyError'> 'first_name') if
there is no first and last name fields in the database. If I create
them but make them unreadable and unwritable the page will load but
all of the entries in the User ID dropdown say "None None (user ID
#)".

The auth Welcome bar is also fixed to the first name field and if not
used it will says Welcome, None.

This seems like quite a huge oversight for such a robust auth system.
Usernames are far more common for user management than first and last
names and many people just plain refuse to give their real names to
random web sites that require authentication.

Is there a modded version of auth perhaps that can be used as a
plugin? Excuse me if that sounds stupid, I'm just started out with
this and could very well just be going about this all wrong.

Massimo Di Pierro

ยังไม่อ่าน,
29 ม.ค. 2555 20:14:0929/1/55
ถึง web2py-users
I suggest you simply make the fields hidden

db.auth_user.first_name.readable = db.auth_user.first_name.writable =
False
db.auth_user.last_name.readable = db.auth_user.last_name.writable =
False

Anthony

ยังไม่อ่าน,
30 ม.ค. 2555 09:51:4530/1/55
ถึง web...@googlegroups.com
On Sunday, January 29, 2012 7:36:07 PM UTC-5, HittingSmoke wrote:
I'd like to use auth with only a username instead of first and last
name. I defined my own tables without a first and last name but it
still causes issues throughout the app.

For instance, when I try to use appadmin to add a user to a new auth
group I get an error (<type 'exceptions.KeyError'> 'first_name') if
there is no first and last name fields in the database. If I create
them but make them unreadable and unwritable the page will load but
all of the entries in the User ID dropdown say "None None (user ID
#)".

The default validator for auth_permission.user_id and auth_event.user_id is:

IS_IN_DB(db, '%s.id' % settings.table_user_name,
    '%(first_name)s %(last_name)s (%(id)s)')

After calling auth.define_tables(), you can change those to:

db.auth_permission.user_id.requires = IS_IN_DB(db, '%s.id' %
    settings.table_user_name, '%(username)s (%(id)s)')

Perhaps this should happen automatically when the first_name and last_name fields are not included in auth_user.

The auth Welcome bar is also fixed to the first name field and if not
used it will says Welcome, None.

You can easily replace the navbar by removing auth.navbar from the layout.html view and replacing it with a custom navbar. However, we should make auth.navbar more customizable. Please open an issue (http://code.google.com/p/web2py/issues/list) and reference this thread.

Anthony

Massimo Di Pierro

ยังไม่อ่าน,
30 ม.ค. 2555 11:06:0530/1/55
ถึง web2py-users
Agree. I will take a patch

HittingSmoke

ยังไม่อ่าน,
30 ม.ค. 2555 20:59:0330/1/55
ถึง web2py-users
Thank you. The issue has been submitted with a link back to this
thread.

HittingSmoke

ยังไม่อ่าน,
19 ต.ค. 2555 19:19:0119/10/55
ถึง web...@googlegroups.com
The issue says fixed, so am I to understand there's now a way to customize the auth.navbar Welcome message that hasn't been documented yet or was this simply a fix for the breakage issues?

Alexei Vinidiktov

ยังไม่อ่าน,
8 ธ.ค. 2559 09:14:518/12/59
ถึง web2py-users
I've added these lines, and now the fields are hidden both on the signup page and on the profile page.

How can I make the fields hidden only on the signup page? 

I want the user to be able to add their name later on the profile page.

黄祥

ยังไม่อ่าน,
8 ธ.ค. 2559 16:28:268/12/59
ถึง web2py-users
i think you can use conditional if to check the url and then hide the fields
e.g.
if 'register' in request.args :
db.auth_user.first_name.readable = db.auth_user.first_name.writable = False
db.auth_user.last_name.readable = db.auth_user.last_name.writable = False 

best regards,
stifan

Alexei Vinidiktov

ยังไม่อ่าน,
9 ธ.ค. 2559 10:40:519/12/59
ถึง web...@googlegroups.com
Thanks, stifan.

Now, the only problem is the first and last name fields on the profile page are required. Can I make them optional?

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alexei Vinidiktov

黄祥

ยังไม่อ่าน,
9 ธ.ค. 2559 16:36:169/12/59
ถึง web2py-users
pls try
models/db.py
custom_auth_table = db[auth.settings.table_user_name] # get the custom_auth_table

custom_auth_table.first_name.notnull = False
custom_auth_table.last_name.notnull = False
custom_auth_table.first_name.required = False
custom_auth_table.last_name.requires = False

auth.settings.table_user = custom_auth_table

ref:

best regards,
stifan
ตอบทุกคน
ตอบกลับผู้สร้าง
ส่งต่อ
ข้อความใหม่ 0 รายการ