Can you please check something for me:
python web2py.py -S yourappname -M
>>> rows = db(db.auth_user).select(db.auth_user.password)
>>> print 'check:', any(r.passwords.startswith('|') for r in rows):
does it print check: true or check: false?
Massimo
On Tuesday, 18 December 2012 13:40:41 UTC-6, Wonton wrote:
>
> Hi again Massimo!
>
> Since I've changed very few from the basic project I will paste my code
> here (sorry for my comments and variable names in Spanish, if you want I
> could translate the code) .
>
> This is my default.py file:
>
> servicios_publicos=Service()
> servicios_privados=Service()
>
> def public_call():
> return servicios_publicos()
>
> @auth.requires_login()
> def private_call():
> return servicios_privados()
>
> @servicios_publicos.json
> def registra(usuario, email, password):
> respuesta = {}
> estado = 'OK'
> mensaje = ''
> tipoError = 0
> #Comprueba si hay otro usuario con el mismo nombre
> if db(db.auth_user.username == usuario).count() != 0:
> estado = 'Error'
> tipoError = 1
> #Comprueba si hay otro usuario con el mismo email
> if db(db.auth_user.email == email).count() != 0:
> estado = 'Error'
> tipoError = tipoError + 2
> #Registrar
> if estado == 'OK':
> db.auth_user.insert(username=usuario, email=email, password=db.
> auth_user.password.validate(password))
> mensaje = 'El registro se ha realizado correctamente.'
> else:
> if tipoError == 1:
> mensaje = 'El usuario ya existe.'
> elif tipoError == 2:
> mensaje = 'El email ya existe.'
> else:
> mensaje = 'El usuario y el email ya existen.'
> respuesta['estado'] = estado
> respuesta['mensaje'] = mensaje
> return respuesta
>
> @servicios_publicos.json
> def login(usuario, password):
> respuesta = {}
> user = auth.login_bare(usuario, password)
> if not user:
> respuesta['estado'] = 'Error'
> respuesta['mensaje'] = 'Nombre de usuario o contraseña incorrecta'
> else:
> respuesta['estado'] = 'OK'
> respuesta['mensaje'] = 'Login correcto'
> return respuesta
>
>
> And this is my db.py:
>
> if not request.env.web2py_runtime_gae:
> ## if NOT running on Google App Engine use SQLite or other DB
> db = DAL('sqlite://storage.sqlite')
> else:
> ## connect to Google BigTable (optional
> 'google:datastore://namespace')
> db = DAL('google:datastore')
> ## store sessions and tickets there
> session.connect(request, response, db=db)
> ## or store session in Memcache, Redis, etc.
> ## from gluon.contrib.memdb import MEMDB
> ## from google.appengine.api.memcache import Client
> ## session.connect(request, response, db = MEMDB(Client()))
>
> ## by default give a view/generic.extension to all actions from localhost
> ## none otherwise. a pattern can be 'controller/function.extension'
> response.generic_patterns = ['*'] if request.is_local else []
> ## (optional) optimize handling of static files
> # response.optimize_css = 'concat,minify,inline'
> # response.optimize_js = 'concat,minify,inline'
>
> #########################################################################
> ## Here is sample code if you need for
> ## - email capabilities
> ## - authentication (registration, login, logout, ... )
> ## - authorization (role based authorization)
> ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
> ## - old style crud actions
> ## (more options discussed in gluon/tools.py)
> #########################################################################
>
> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
> auth = Auth(db)
> crud, service, plugins = Crud(db), Service(), PluginManager()
>
> ## create all tables needed by auth if not custom tables
> auth.define_tables(username=True, signature=False)
>
> ## configure email
> mail = auth.settings.mailer
> mail.settings.server = '<here comes my SMTP server>'
> mail.settings.sender = '<here comes my email>'
> mail.settings.login = '<here comes my email user/password>'
>
> ## configure auth policy
> auth.settings.registration_requires_verification = False
> auth.settings.registration_requires_approval = False
> auth.settings.reset_password_requires_verification = True
>
> ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
> ## register with janrain.com, write your domain:api_key in
> private/janrain.key
> from gluon.contrib.login_methods.rpx_account import use_janrain
> use_janrain(auth, filename='private/janrain.key')
>
> If it helps you, I'm using python 2.7.1 and I launch web2py with:
> python web2py.py -c server.crt -k server.key
> and this is the trace:
> Database drivers available: SQLite(sqlite3), MySQL(pymysql),
> PostgreSQL(pg8000), IMAP(imaplib)
>
> El martes, 18 de diciembre de 2012 18:11:51 UTC+1, Massimo Di Pierro
> escribió:
>>
>> Can I see you models? Are you changing the validator for
>> db.auth_user.password?
>> Your error says:
>>
>> <type 'exceptions.ValueError'> unsupported hash type
>> |pbkdf2(1000,20,sha512)
>>
>> I do not understand where | in |pbkdf2 would come from.
>>
>>
>> On Tuesday, 18 December 2012 09:33:12 UTC-6, Wonton wrote:
>>>
>>> Hi Massimo!!
>>>
>>> I'm using version 2.2.1 (2012-10-21 16:57:04) stable. I dowloaded it
>>> last week.
>>>
>>> El martes, 18 de diciembre de 2012 16:26:29 UTC+1, Massimo Di Pierro
>>> escribió:
>>>>
>>>> Which web2py version? The error suggests you are using an older web2py
>>>> version with newly created database of records.
>>>>
>>>> Massimo
>>>>
>>>> On Monday, 17 December 2012 14:59:02 UTC-6, Wonton wrote:
>>>>>
>>>>> Hello everyone,
>>>>>
>>>>> I'm developing a backend site with web2py. I have 2 web services, one
>>>>> to register a user and a second one to login the user.
>>>>> This is the first one:
>>>>>
>>>>> def register(user, email, password):
>>>>> db.auth_user.insert(username=user, email=email,
>>>>> password=db.auth_user.password.validate(password))
>>>>> ...
>>>>> return 'OK'
>>>>>
>>>>> It's working ok and the users are created without problem.
>>>>>
>>>>> This is the second one:
>>>>>
>>>>> def login(user, password):
>>>>> response = auth.login_bare(user, password)
>>>>> if not response:
>>>>> message = 'Error'
>>>>> else:
>>>>> message = 'OK'
>>>>> return message
>>>>>
>>>>> With this service I have the following error:
>>>>> <type 'exceptions.ValueError'> unsupported hash type
>>>>> |pbkdf2(1000,20,sha512)
>>>>>
>>>>> I've tried to find any solution to this problem without success.
>>>>>
>>>>> Any of you has any idea of what is happening?
>>>>>
>>>>> Thank you very much and kind regards!
>>>>>
>>>>> Wonton
>>>>>
>>>>
--