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