I wanted to play with other login methods. Therefore I created a new
application called "alt_login" - it started with no problems.
Next step: I copied the definition of my own "auth_table" from the book into
alt_login.
Here are the lines of code:
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db, hmac_key=Auth.get_or_create_key())
crud, service, plugins = Crud(db), Service(), PluginManager()
# copied from the book:
db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default=''),
Field('last_name', length=128, default=''),
Field('email', length=128, default='', unique=True),
Field('password', 'password', length=512,
readable=False, label='Password'),
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=''))
auth_table.first_name.requires = \
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.last_name.requires = \
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.password.requires = [IS_STRONG(), CRYPT()]
auth_table.email.requires = [
IS_EMAIL(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB(db, auth_table.email)]
auth.settings.table_user = auth_table
# end of copy
## create all tables needed by auth if not custom tables
auth.define_tables()
Result: a ticket with
Traceback (most recent call last):
File "/etc/web2py/gluon/restricted.py", line 194, in restricted
exec ccode in environment
File "/etc/web2py/applications/alt_login/models/db.py"
<https://secure.infosms.org:8000/admin/default/edit/alt_login/models/db.py>,
line 56, in <module>
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
NameError: name 'auth_table' is not defined
I have tried it without the line "auth.define_tables()" - same result.
Any ideas?
Regards, Martin