On Thursday, April 28, 2011 7:42:15 AM UTC-4, 黄祥 wrote:
>
> hello,
>
> thank you so much for your pointer, salbefe. i can input the encrypted
> password but the result not like i've expected before. i mean there is an
> additional character on the field password.
> e.g.
> db.auth_user.bulk_insert([{'first_name' : 'a',
> 'last_name' : 'a',
> 'email' : 'a.a.com',
> 'password' :
> db.auth_user.password.validate('a')}])
>
> i created 1 user with password string '*a' (without quotes)*, and second 1
> register new password with the same password string '*a'** (without
> quotes)*, when i compare it on the db the result that i entered manual
> password string '*a' (without quotes)* via register form is not match
> that i store on the database via python script. the differnetial on the
> password field is there is *|encrypted_password|None* when i put it via
> python script.
>
the validate() method of the field runs the validator associated with the
field, and the validator returns a (value, error) tuple (where error = None
if the validation passed). So, when you run
db.auth_user.password.validate('a'), you're getting back a tuple like
(hashed_password, None). When you try to insert a list or tuple into a field
via DAL, it converts the items in the list into a string separated by '|'
characters, which is why you're getting |encrypted_password|None. So,
instead, just insert the first item in the tuple returned by validate:
db.auth_user.password.validate('a')[0]
Anthony
>
> maybe i've missed something, please give me a hints about this, thank you
> very much before.
>
> On Thu, Apr 28, 2011 at 3:19 PM, salbefe <[email protected]> wrote:
>
>> Hello,
>>
>> Yo can do this:
>>
>>
>>
>> db.auth_user.insert(first_name=...,last_name=...,email=...,password=db.auth_user.password.validate(myPassword))
>>
>>
>>
>> On 28 abr, 08:36, 黄祥 <[email protected]> wrote:
>> > hi,
>> >
>> > is there a way to input encrypted user password for the first time
>> > execution? i mean like
>> > e.g.
>> > db.auth_user.bulk_insert([{'first name' : 'a', 'last name' : 'a',
>> > 'email' : 'a.a.com', 'password' : 'a'}, {'first name' : 'b', 'last
>> > name' : 'b', 'email' : 'b.b.com', 'password' : 'b'}])
>> >
>> > i can using this bulk insert but, the password didn't encryted. and
>> > the other is there alternative way to do that maybe something like :
>> > e.g.
>> > auth.add_user('first name', 'last_name', 'email', 'password')
>> >
>> > please give an advice or pointer about this,
>> >
>> > thank you very much before
>
>
>