Skip to content

Instantly share code, notes, and snippets.

@rochacbruno
Created July 13, 2011 19:59
Show Gist options
  • Save rochacbruno/1081193 to your computer and use it in GitHub Desktop.
Save rochacbruno/1081193 to your computer and use it in GitHub Desktop.
#auth table
# Custom Auth table definition
db.define_table(auth.settings.table_user_name,
Field('name', length=128, default='', comment='required'),
Field('email', length=128, default='', unique=True),
Field('phone', length=64, default=''),
Field('homepage', requires=IS_EMPTY_OR(IS_URL())),
Field('bio', 'text', default=''),
Field('twitter'),
Field('facebook'),
Field('photo_source','integer',requires=IS_EMPTY_OR(IS_IN_SET(PHOTO_SOURCES))),
Field('photo_url','string',length=512,requires=IS_EMPTY_OR(IS_URL())),
Field('photo','upload', uploadfolder=request.folder+'static/uploads',requires=IS_EMPTY_OR(IS_IMAGE())),
Field('photo_thumb', 'upload', writable=False, readable = False, compute=lambda r: THUMB(r['photo'])),
Field('password', 'password', length=64, 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=''),
Field('record_created', 'datetime', default=request.now, writable=False,
readable=False),
Field('record_updated', 'datetime', default=request.now,
update=request.now, writable=False, readable=False),
migrate = settings.migrate
)
custom_auth_table = db[auth.settings.table_user_name] # get the custom_auth_table
custom_auth_table.name.requires = IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.password.requires = [CRYPT(key=auth.settings.hmac_key)]
custom_auth_table.email.requires = [
IS_EMAIL(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB(db, custom_auth_table.email)]
custom_auth_table.photo_url.readable = custom_auth_table.photo_url.writable = False
auth.settings.table_user = custom_auth_table
auth.define_tables(migrate = settings.migrate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment