Hi
I am new to Web2py, so I apologize in advance if this is basic.
So, I am wanting to create a custom login, that does not require someone to
enter an email. So, following some of the examples I have found out there,
I created a custom auth table, with a username, etc. (I paste the code
below). So my issue is, that on my local instance this is working fine. I
am able to create multiple new accounts that do not require an email.
However, when I attempt to do the same on an amazon instance I created, I
am getting the following message:
<class 'sqlite3.IntegrityError'> UNIQUE constraint failed: auth_user.email
So clearly this is related to the auth_user.email column requiring it to be
unique (and I can create at least one account, and if I delete that record,
I can create a new account again). However, since it is forcing me to have
the email field be unique, this means I cannot ever create more than the
initial email account (this is even if I change Field('email' to be
unique=False)
I could create a custom form, and generate some dummy unique email each
time, etc. But is there not some standard way this should work? Or some way
through the DAL that I can change the "unique" field requirement on this
particular column, so that I quit having this issue? Or, is it maybe how I
implemented the custom auth table that is causing the issue (code below)?
Thanks for any assistance. And here is my code:
in default.py
def index():
#some action here
return dict(form=auth.register())
in db.py
db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default='', writable=False,
readable=False),
Field('last_name', length=128, default='', writable=False,
readable=False, ),
Field('username', length=128, default='', unique=True),
Field('email', length=128, default='', unique=False, writable=False,
readable=False), # required
Field('password', 'password', length=512, # required
readable=False, label='Password'),
Field('registration_key', length=512, # required
writable=False, readable=False, default=''),
Field('reset_password_key', length=512, # required
writable=False, readable=False, default=''),
Field('registration_id', length=512, # required
writable=False, readable=False, default=''))
## do not forget validators
custom_auth_table = db[auth.settings.table_user_name] # get the
custom_auth_table
custom_auth_table.first_name.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.last_name.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.username.requires = IS_NOT_IN_DB(db,
custom_auth_table.username)
custom_auth_table.password.requires = [IS_STRONG(min=15, special=0,
upper=0), CRYPT()]
auth.settings.table_user = custom_auth_table # tell auth to use
custom_auth_table
## before auth.define_tables()
auth.define_tables(username=True, signature=False, migrate=False)
auth.settings.remember_me_form=False
auth.settings.actions_disabled = ['retrieve_username',
'request_reset_password']
auth.settings.login_next = URL([some redirect here])
auth.settings.register_next = URL([some redirect here])
## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
#auth.settings.reset_password_requires_verification = True
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.