[web2py] Re: put signature on custom auth table
I think it is much safer to use auth.settings.extra_fields['auth_user'] = [ ] First create the table without signature, then migrate it with (signature=True). On Friday, 23 January 2015 16:04:11 UTC-6, 黄祥 wrote: > > hi, > > is it possible to put signature on custom auth table? > e.g. taken from book > > ## after auth = Auth(db) > db.define_table( > auth.settings.table_user_name, > Field('name', length=128, default=''), > Field('email', length=128, default='', unique=True), # required > Field('username', length=128, default='', unique=True), > Field('password', 'password', length=512,# required > readable=False, label='Password'), > Field('address'), > Field('city'), > Field('zip'), > Field('phone'), > 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=''), > Field('is_active', 'boolean', default=True), > Field('created_on', 'datetime', default=request.now), > Field('updated_on', 'datetime', update=request.now) ) > > ## do not forget validators > 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 = [IS_STRONG(), CRYPT()] > 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.username.requires = IS_NOT_IN_DB(db, > custom_auth_table.username) > > auth.settings.table_user = custom_auth_table # tell auth to use > custom_auth_table > > ## before auth.define_tables() > > auth.define_tables(username=True, signature=True) > > this one is work, my question is > 1. why auth.define_tables(username=True, signature=True) is not work when > i redefine the auth_user? (i must explicit put the username field and > signature on the table definition) > 2. how can i put the created_on and modified_on in the example above? > tried : > Field('created_by', auth.settings.table_user_name), > or > Field('created_by', db.auth_user), > > it returns an error. > > thanks and best regards, > stifan > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: put signature on custom auth table
i've read that on the book, but the problem is, i want to replace first name and last name fields with 1 field name. any idea how to achieve it using web2py way? thanks and best regards, stifan -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: put signature on custom auth table
I think that should be an auth option. In some cultures it gets really messy what a last name and a first name is. Name only is really the only correct way. -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: put signature on custom auth table
+ 1 for Name only option. What I do is create an extra field: auth.settings.extra_fields['auth_user'] = [ Field('u_name') ] Then define tables without "username" because I want to use email for login: auth.define_tables(username=False, signature=True) Then hide the first and last names by making them unreadable and unwritable: auth.settings.table_user.first_name.writable = auth.settings.table_user.first_name.readable = False auth.settings.table_user.last_name.writable = auth.settings.table_user.last_name.readable = False The first and last names show up in data base as blank columns, but it is a quick work-around. Plus later I could but both fields on a "profile" view (by making them readable and writeable there) and let user fill in as optional fields if they like. On Friday, January 23, 2015 at 6:01:53 PM UTC-7, Leonel Câmara wrote: > > I think that should be an auth option. In some cultures it gets really > messy what a last name and a first name is. Name only is really the only > correct way. > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: put signature on custom auth table
thanks cynthia for the trick. i use custom auth table for that. e.g. auth.settings.extra_fields['auth_user']= [ Field('name') ] # create all tables needed by auth if not custom tables auth.define_tables(username = True, signature = True) """ custom_auth_table """ custom_auth_table = db[auth.settings.table_user_name] # format custom_auth_table._format = '%(name)s' # readable custom_auth_table.first_name.readable = False custom_auth_table.last_name.readable = False # writable custom_auth_table.first_name.writable = False custom_auth_table.last_name.writable = False auth.settings.table_user = custom_auth_table best regards, stifan -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.