try something like this... may need more tweaks
# define a function that upon registration sets a random password and sends
it by sms
def login_callback(form):
from gluon.utils import web2py_uuid
token = web2py_uuid()
form.record.update_record(password=db.auth_user.password.validate(token))
send_sms(phone_number=form.username, message = token)
# define auth_user with a username field
auth.define_tables(username=True)
# pretend the username is the phone number
db.auth_user.username.label = 'phone number'
# do not allow login after registration but skip email validation
auth.settings.requires_approval = True
auth.settings.requires_verification = False
# after registration go back to login form
auth.settings.register_next = URL('user/login')
# before that generate random password and send it by sms
auth.settings.register_onaccept = login_callback
send_sms is not a web2py function. You need a third party service for that.
On Sunday, 15 July 2012 08:48:48 UTC-5, Pystar wrote:
>
> I am confused on how to implement this strange authentication mechanism
> and incorporate it into web2py and make it work natively.
> Take this as an example of how it would work:
> There is no registration on the site, whenever a user wants to login to
> perform any action, he clicks in the login button, which takes him to a
> form where he enters his phone number and a random alphanumeric code is
> generated and sent to his phone which he now enters and gets authenticated
> and he can now perform whatever action he wants.
> How do I get this to play with login_bare() and @auth.requires_login()?
> I need responses ASAP,
> Thanks
>