On Friday, May 20, 2011 7:00:08 PM UTC-4, haggis wrote:
>
> Hi,
> since I doesn't need any email adresses associated with my users, I
> changed the schema of the auth_user table like this:
>
> file: db.py
>
> <snip>
> db.define_table(
> auth.settings.table_user_name,
> Field('name', length=32, default='', label='Name'),
> Field('password', 'password', length=512, readable=False,
> label='Passwort'),
> Field('registration_key', length=512, writable=False,
> readable=False, default=''),
> Field('reset_password_key', length=512, writable=False,
> readable=False, default=''),
> Field('registration_id', length=512, writable=False,
> readable=False, default=''))
>
> custom_auth_table = db[auth.settings.table_user_name]
> custom_auth_table.name.requires =
> [IS_NOT_EMPTY(error_message=auth.messages.is_empty),
> IS_NOT_IN_DB(db,
> custom_auth_table.name)]
> custom_auth_table.password.requires =
> CRYPT(key=auth.settings.hmac_key)
>
> auth.settings.table_user = custom_auth_table
>
> auth.define_tables(username=True)
Do you want your auth_user table to include a 'username' field? If so, as
long as you are creating a custom table, I think you have to add that field
manually. If you call auth.define_tables(username=True), I believe that will
only define auth tables that have not already been defined, so it will not
re-define your auth_user table and will therefore not add a 'username' field
to it for you (i.e., username=True will simply be ignored).
The Auth code that builds the login form first checks to see if there is an
auth.settings.login_userfield defined. If not, it checks to see if the
auth_user table includes a 'username' field, and if not, it uses the 'email'
field as the login field. So, if you haven't set
auth.settings.login_userfield and don't have a 'username' field, it will
assume you've got an 'email' field to use for login -- that's probably why
you're getting the error. So, you should either add a 'username' field, or
if you want to use the 'name' field for login, then set
auth.settings.login_userfield='name'.
Anthony