Re: [web2py] Re: password encrypt during insert

2013-05-08 Thread vikas gupta
i had forgotten to add [0], didnt help though. still got the same 
error login_bare worked though i could pass login and password and 
it validated the user for me...
Does login_bare do anything with respect to the session or does it just 
validate the fact that the user exists and password is correct. How do I 
associate a session with a user login without calling  the form.

this is what I am doing right now.

logged_user=auth.login_bare(myemail, mypassword.encode('utf8'))
logger.debug(bare login returned - %s % logged_user)

ret=
if (logged_user == False):
logger.debug(user with email - %s not found with bare login % 
myemail)
ret=[error]
else:
logger.debug(user logged in with bare login, email - %s found % 
myemail)
ret=response.session_id

-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-07 Thread 黄祥
please try this (please ensure that you have the empty db.auth_user):

models/db_insert_auth_user.py
if db(db.auth_user).isempty():
db.auth_user.bulk_insert([{'first_name' : 'Manager', 'last_name' : 
'Manager', 
   'email' : 'mana...@gmail.com', 
   'password' : 
db.auth_user.password.validate('mypassword')[0],
   'gender' : 'Male', 'address' : 'Address', 
'zip_code' : '1',
   'city' : 'city', 'country' : 'country', 
'phone' : '1'}, 
  {'first_name' : 'Admin', 'last_name' : 
'Admin', 
   'email' : 'ad...@gmail.com', 
   'password' : 
db.auth_user.password.validate('mypassword')[0],
   'gender' : 'Male', 'address' : 'Address', 
'zip_code' : '1',
   'city' : 'city', 'country' : 'country', 
'phone' : '2'}])

-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-07 Thread vikas gupta
something weird here, my messages arent getting reflected... trying again.

this is what i get from the print statement:

gluon.validators.LazyCrypt object at 0xac526eec

the bulk insert was successful... i can see the records in the db. password 
is encrypted.

-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-07 Thread Massimo Di Pierro
I now see the problem:

encpasswd=db.auth_user.password.validate(mypassword)[0]
logger.debug(encrypted passwd - %s % encpasswd)

should be

encpasswd=db.auth_user.password.validate(mypassword)[0]
logger.debug(encrypted passwd - %s % str(encpasswd))

because the encrypted password is not a string but an object. It turns into 
a string only when serialized.


On Tuesday, 7 May 2013 04:06:49 UTC-5, vikas gupta wrote:

 something weird here, my messages arent getting reflected... trying again.

 this is what i get from the print statement:

 gluon.validators.LazyCrypt object at 0xac526eec

 the bulk insert was successful (after deleting some fields from the 
 statements as those arent there in the table)... i can see the records in 
 the db. password is encrypted.


-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-07 Thread vikas gupta
I tried that.. now the logger statement throws the same error:

File /home/www-data/web2py/applications/trotez/controllers/default.py, 
line 185, in userRegister
logger.debug(encrypted passwd - %s % str(encpasswd))
  File /home/www-data/web2py/gluon/validators.py, line 2760, in __str__
hashed = simple_hash(self.password, key, salt, digest_alg)
  File /home/www-data/web2py/gluon/utils.py, line 87, in simple_hash
int(keylen), get_digest(alg))
  File /home/www-data/web2py/gluon/contrib/pbkdf2.py, line 55, in 
pbkdf2_hex
return pbkdf2_bin(data, salt, iterations, keylen, 
hashfunc).encode('hex')
  File /home/www-data/web2py/gluon/contrib/pbkdf2.py, line 65, in 
pbkdf2_bin
mac = hmac.new(data, None, hashfunc)
  File /usr/lib/python2.7/hmac.py, line 133, in new
return HMAC(key, msg, digestmod)
  File /usr/lib/python2.7/hmac.py, line 72, in __init__
self.outer.update(key.translate(trans_5C))
TypeError: character mapping must return integer, None or unicode

-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-07 Thread Massimo Di Pierro
What is the un-encrypted password? I suspect, there is something in there 
which is not unicode.

On Tuesday, 7 May 2013 09:01:53 UTC-5, vikas gupta wrote:

 I tried that.. now the logger statement throws the same error:

 File /home/www-data/web2py/applications/trotez/controllers/default.py, 
 line 185, in userRegister
 logger.debug(encrypted passwd - %s % str(encpasswd))
   File /home/www-data/web2py/gluon/validators.py, line 2760, in __str__
 hashed = simple_hash(self.password, key, salt, digest_alg)
   File /home/www-data/web2py/gluon/utils.py, line 87, in simple_hash
 int(keylen), get_digest(alg))
   File /home/www-data/web2py/gluon/contrib/pbkdf2.py, line 55, in 
 pbkdf2_hex
 return pbkdf2_bin(data, salt, iterations, keylen, 
 hashfunc).encode('hex')
   File /home/www-data/web2py/gluon/contrib/pbkdf2.py, line 65, in 
 pbkdf2_bin
 mac = hmac.new(data, None, hashfunc)
   File /usr/lib/python2.7/hmac.py, line 133, in new
 return HMAC(key, msg, digestmod)
   File /usr/lib/python2.7/hmac.py, line 72, in __init__
 self.outer.update(key.translate(trans_5C))
 TypeError: character mapping must return integer, None or unicode



-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-07 Thread vikas gupta
i havent specified unicode.. passwd is abc123

On Tuesday, May 7, 2013 10:02:07 PM UTC+5:30, Massimo Di Pierro wrote:

 What is the un-encrypted password? I suspect, there is something in there 
 which is not unicode.

 On Tuesday, 7 May 2013 09:01:53 UTC-5, vikas gupta wrote:

 I tried that.. now the logger statement throws the same error:

 File /home/www-data/web2py/applications/trotez/controllers/default.py, 
 line 185, in userRegister
 logger.debug(encrypted passwd - %s % str(encpasswd))
   File /home/www-data/web2py/gluon/validators.py, line 2760, in __str__
 hashed = simple_hash(self.password, key, salt, digest_alg)
   File /home/www-data/web2py/gluon/utils.py, line 87, in simple_hash
 int(keylen), get_digest(alg))
   File /home/www-data/web2py/gluon/contrib/pbkdf2.py, line 55, in 
 pbkdf2_hex
 return pbkdf2_bin(data, salt, iterations, keylen, 
 hashfunc).encode('hex')
   File /home/www-data/web2py/gluon/contrib/pbkdf2.py, line 65, in 
 pbkdf2_bin
 mac = hmac.new(data, None, hashfunc)
   File /usr/lib/python2.7/hmac.py, line 133, in new
 return HMAC(key, msg, digestmod)
   File /usr/lib/python2.7/hmac.py, line 72, in __init__
 self.outer.update(key.translate(trans_5C))
 TypeError: character mapping must return integer, None or unicode



-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-07 Thread vikas gupta
another message disappeared... i think i clicked the wrong button, reply to 
author instead of post... sorry massimo, my messages might come to you as a 
PM. will be careful in future.

I got the insert to work with this, I guess unicode is needed.

db.auth_user.bulk_insert([{'first_name' : myname,
'email' : myemail,
'password' : 
db.auth_user.password.validate(mypassword.encode('utf8'))[0]
}])

But now I am having issues with validating the logins.. I tried these 
statements password matching fails.

record = db(db.auth_user.email == myemail ).select()
if len(record):
logger.debug(user with email - %s found % myemail)
else:
logger.debug(user with email - %s not found % myemail)

record = db(db.auth_user.password == 
db.auth_user.password.validate(mypassword.encode('utf8'))).select()
if len(record):
logger.debug(user with email - %s has valid password % myemail)
else:
logger.debug(user with email - %s does not have a valid password 
% myemail)

And tried this combined one also.

record = db(db.auth_user.email == myemail and db.auth_user.password == 
db.auth_user.password.validate(mypassword.encode('utf8'))).select()

-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-06 Thread vikas gupta
I am trying this and I am getting errors:

id=db.auth_user.insert( email=myemail, 
password=(db.auth_user.password.validate(mypassword)[0]), first_name=myname)

I get this error:
TypeError: character mapping must return integer, None or unicode

  File /home/www-data/web2py/applications/trotez/controllers/default.py, 
line 171, in userRegister
id=db.auth_user.insert( email=myemail, 
password=db.auth_user.password.validate(mypassword)[0], first_name=myname)
  File /home/www-data/web2py/gluon/dal.py, line 8514, in insert
ret =  self._db._adapter.insert(self, self._listify(fields))
  File /home/www-data/web2py/gluon/dal.py, line 1199, in insert
query = self._insert(table,fields)

Something I am doing wrong?


On Friday, April 29, 2011 12:56:06 AM UTC+5:30, 黄祥 wrote:

 yes, u right, ron, there is a mistaken on my field value, thanks for show 
 me my wrong code, it's work right now. thank you all for your pointer.

 On Fri, Apr 29, 2011 at 12:10 AM, ron_m ron.m...@gmail.com 
 javascript:wrote:

 email of a.a.com is not a valid email address according to your code.
 I am not sure if there is any validation during login




-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-06 Thread 黄祥
please use '  for string data type
e.g.
db.auth_user.insert('email' : 'myem...@gmail.com', 'password' : 
db.auth_user.password.validate('mypassword')[0], 'first_name' : 'myname')

best regards

On Monday, May 6, 2013 1:11:02 PM UTC-4, vikas gupta wrote:

 I am trying this and I am getting errors:

 id=db.auth_user.insert( email=myemail, 
 password=(db.auth_user.password.validate(mypassword)[0]), first_name=myname)

 I get this error:
 TypeError: character mapping must return integer, None or unicode

   File /home/www-data/web2py/applications/trotez/controllers/default.py, 
 line 171, in userRegister
 id=db.auth_user.insert( email=myemail, 
 password=db.auth_user.password.validate(mypassword)[0], first_name=myname)
   File /home/www-data/web2py/gluon/dal.py, line 8514, in insert
 ret =  self._db._adapter.insert(self, self._listify(fields))
   File /home/www-data/web2py/gluon/dal.py, line 1199, in insert
 query = self._insert(table,fields)

 Something I am doing wrong?


 On Friday, April 29, 2011 12:56:06 AM UTC+5:30, 黄祥 wrote:

 yes, u right, ron, there is a mistaken on my field value, thanks for show 
 me my wrong code, it's work right now. thank you all for your pointer.

 On Fri, Apr 29, 2011 at 12:10 AM, ron_m ron.m...@gmail.com wrote:

 email of a.a.com is not a valid email address according to your code.
 I am not sure if there is any validation during login




-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-06 Thread vikas gupta
I tried this:
 id=db.auth_user.insert( 'email':myemail, 
'password':(db.auth_user.password.validate(mypassword)[0]), 
'first_name':myname)

I get a syntax error at the first ':'

myemail, mypassword and myname are string variables and are populated 
correctly. In my original statement, putting field names in quotes didnt 
help. 
When I tried this -
id=db.auth_user.insert( 'email'=myemail, 
'password'=(db.auth_user.password.validate(mypassword)[0]), 
'first_name'=myname)
I get this error:
SyntaxError: keyword can't be an expression

On Monday, May 6, 2013 11:13:39 PM UTC+5:30, 黄祥 wrote:

 please use '  for string data type
 e.g.
 db.auth_user.insert('email' : 'mye...@gmail.com javascript:', 
 'password' : db.auth_user.password.validate('mypassword')[0], 'first_name' 
 : 'myname')

 best regards

 On Monday, May 6, 2013 1:11:02 PM UTC-4, vikas gupta wrote:

 I am trying this and I am getting errors:

 id=db.auth_user.insert( email=myemail, 
 password=(db.auth_user.password.validate(mypassword)[0]), first_name=myname)

 I get this error:
 TypeError: character mapping must return integer, None or unicode

   File 
 /home/www-data/web2py/applications/trotez/controllers/default.py, line 
 171, in userRegister
 id=db.auth_user.insert( email=myemail, 
 password=db.auth_user.password.validate(mypassword)[0], first_name=myname)
   File /home/www-data/web2py/gluon/dal.py, line 8514, in insert
 ret =  self._db._adapter.insert(self, self._listify(fields))
   File /home/www-data/web2py/gluon/dal.py, line 1199, in insert
 query = self._insert(table,fields)

 Something I am doing wrong?


 On Friday, April 29, 2011 12:56:06 AM UTC+5:30, 黄祥 wrote:

 yes, u right, ron, there is a mistaken on my field value, thanks for 
 show me my wrong code, it's work right now. thank you all for your pointer.

 On Fri, Apr 29, 2011 at 12:10 AM, ron_m ron.m...@gmail.com wrote:

 email of a.a.com is not a valid email address according to your code.
 I am not sure if there is any validation during login




-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-06 Thread Massimo Di Pierro
This is not valid pyhton syntax

 id=db.auth_user.insert(email=myemail, 
password=db.auth_user.password.validate(mypassword)[0], first_name=myname)

or 

 id=db.auth_user.insert( **{'email':myemail, 
'password':(db.auth_user.password.validate(mypassword)[0]), 
'first_name':myname})


On Monday, 6 May 2013 22:47:37 UTC-5, vikas gupta wrote:

 I tried this:
  id=db.auth_user.insert( 'email':myemail, 
 'password':(db.auth_user.password.validate(mypassword)[0]), 
 'first_name':myname)

 I get a syntax error at the first ':'

 myemail, mypassword and myname are string variables and are populated 
 correctly. In my original statement, putting field names in quotes didnt 
 help. 
 When I tried this -
 id=db.auth_user.insert( 'email'=myemail, 
 'password'=(db.auth_user.password.validate(mypassword)[0]), 
 'first_name'=myname)
 I get this error:
 SyntaxError: keyword can't be an expression

 On Monday, May 6, 2013 11:13:39 PM UTC+5:30, 黄祥 wrote:

 please use '  for string data type
 e.g.
 db.auth_user.insert('email' : 'mye...@gmail.com', 'password' : 
 db.auth_user.password.validate('mypassword')[0], 'first_name' : 'myname')

 best regards

 On Monday, May 6, 2013 1:11:02 PM UTC-4, vikas gupta wrote:

 I am trying this and I am getting errors:

 id=db.auth_user.insert( email=myemail, 
 password=(db.auth_user.password.validate(mypassword)[0]), first_name=myname)

 I get this error:
 TypeError: character mapping must return integer, None or unicode

   File 
 /home/www-data/web2py/applications/trotez/controllers/default.py, line 
 171, in userRegister
 id=db.auth_user.insert( email=myemail, 
 password=db.auth_user.password.validate(mypassword)[0], first_name=myname)
   File /home/www-data/web2py/gluon/dal.py, line 8514, in insert
 ret =  self._db._adapter.insert(self, self._listify(fields))
   File /home/www-data/web2py/gluon/dal.py, line 1199, in insert
 query = self._insert(table,fields)

 Something I am doing wrong?


 On Friday, April 29, 2011 12:56:06 AM UTC+5:30, 黄祥 wrote:

 yes, u right, ron, there is a mistaken on my field value, thanks for 
 show me my wrong code, it's work right now. thank you all for your pointer.

 On Fri, Apr 29, 2011 at 12:10 AM, ron_m ron.m...@gmail.com wrote:

 email of a.a.com is not a valid email address according to your code.
 I am not sure if there is any validation during login




-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-06 Thread vikas gupta
I tried this :
id=db.auth_user.insert( **{'email':myemail, 
'password':(db.auth_user.password.validate(mypassword)[0]), 
'first_name':myname})

and still get the same error at this line:
TypeError: character mapping must return integer, None or unicode

I tried the bulk insert:
db.auth_user.bulk_insert([{'first_name' : myname,
'email' : myemail,
'password' : db.auth_user.password.validate(mypassword)[0]}])

I get the same error, the line number points to the third line in the above 
statement, which is the password one.

On Tuesday, May 7, 2013 9:24:08 AM UTC+5:30, Massimo Di Pierro wrote:

 This is not valid pyhton syntax

  id=db.auth_user.insert(email=myemail, 
 password=db.auth_user.password.validate(mypassword)[0], first_name=myname)

 or 

  id=db.auth_user.insert( **{'email':myemail, 
 'password':(db.auth_user.password.validate(mypassword)[0]), 
 'first_name':myname})


 On Monday, 6 May 2013 22:47:37 UTC-5, vikas gupta wrote:

 I tried this:
  id=db.auth_user.insert( 'email':myemail, 
 'password':(db.auth_user.password.validate(mypassword)[0]), 
 'first_name':myname)

 I get a syntax error at the first ':'

 myemail, mypassword and myname are string variables and are populated 
 correctly. In my original statement, putting field names in quotes didnt 
 help. 
 When I tried this -
 id=db.auth_user.insert( 'email'=myemail, 
 'password'=(db.auth_user.password.validate(mypassword)[0]), 
 'first_name'=myname)
 I get this error:
 SyntaxError: keyword can't be an expression

 On Monday, May 6, 2013 11:13:39 PM UTC+5:30, 黄祥 wrote:

 please use '  for string data type
 e.g.
 db.auth_user.insert('email' : 'mye...@gmail.com', 'password' : 
 db.auth_user.password.validate('mypassword')[0], 'first_name' : 'myname')

 best regards

 On Monday, May 6, 2013 1:11:02 PM UTC-4, vikas gupta wrote:

 I am trying this and I am getting errors:

 id=db.auth_user.insert( email=myemail, 
 password=(db.auth_user.password.validate(mypassword)[0]), 
 first_name=myname)

 I get this error:
 TypeError: character mapping must return integer, None or unicode

   File 
 /home/www-data/web2py/applications/trotez/controllers/default.py, line 
 171, in userRegister
 id=db.auth_user.insert( email=myemail, 
 password=db.auth_user.password.validate(mypassword)[0], first_name=myname)
   File /home/www-data/web2py/gluon/dal.py, line 8514, in insert
 ret =  self._db._adapter.insert(self, self._listify(fields))
   File /home/www-data/web2py/gluon/dal.py, line 1199, in insert
 query = self._insert(table,fields)

 Something I am doing wrong?


 On Friday, April 29, 2011 12:56:06 AM UTC+5:30, 黄祥 wrote:

 yes, u right, ron, there is a mistaken on my field value, thanks for 
 show me my wrong code, it's work right now. thank you all for your 
 pointer.

 On Fri, Apr 29, 2011 at 12:10 AM, ron_m ron.m...@gmail.com wrote:

 email of a.a.com is not a valid email address according to your code.
 I am not sure if there is any validation during login




-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: password encrypt during insert

2013-05-06 Thread Massimo Di Pierro
Try 

print repr(db.auth_user.password.validate(mypassword)[0])

what do you get?


On Monday, 6 May 2013 23:22:29 UTC-5, vikas gupta wrote:

 I tried this :
 id=db.auth_user.insert( **{'email':myemail, 
 'password':(db.auth_user.password.validate(mypassword)[0]), 
 'first_name':myname})

 and still get the same error at this line:
 TypeError: character mapping must return integer, None or unicode

 I tried the bulk insert:
 db.auth_user.bulk_insert([{'first_name' : myname,
 'email' : myemail,
 'password' : db.auth_user.password.validate(mypassword)[0]}])

 I get the same error, the line number points to the third line in the 
 above statement, which is the password one.

 I tried this:
 encpasswd=db.auth_user.password.validate(mypassword)[0]
 logger.debug(encrypted passwd - %s % encpasswd)
 and I get the same error on the second line.


-- 

--- 
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/groups/opt_out.




[web2py] Re: password encrypt during insert

2011-04-28 Thread salbefe
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, 黄祥 steve.van.chris...@gmail.com 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


Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread Stifan Kristi
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.

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 salb...@gmail.com 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, 黄祥 steve.van.chris...@gmail.com 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


[web2py] Re: password encrypt during insert

2011-04-28 Thread salbefe
I've been testing and I have the same problem as you. I tried with:

CRYPT()('yourpassword')[0] that I found in other posts but it does not
work too.

I think that we are missing something or that is a bug; perhaps Maximo
could help us.


On 28 abr, 13:42, Stifan Kristi steve.van.chris...@gmail.com 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.

 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 salb...@gmail.com 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, 黄祥 steve.van.chris...@gmail.com 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


Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread Anthony
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 sal...@gmail.com 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, 黄祥 steve.van...@gmail.com 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




Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread Stifan Kristi
thank you so much for your pointer, anthony, the encrypted password is
without *|encrypted password|None.*
i've compared with the manual that i put on the register form is same. (same
password 'a' string)
but, pardon there is strange behaviour during login, the user that i
inserted via script couldn't login, but the manual one could login. is there
anything i missed on my code?
e.g.
db.auth_user.bulk_insert([{'first_name' : 'a',
   'last_name' : 'a',
   'email' : 'a.a.com',
   'password' :
db.auth_user.password.validate('a')[0]}])

thank you very much before.

On Thu, Apr 28, 2011 at 9:46 PM, Anthony abasta...@gmail.com wrote:

 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 sal...@gmail.com 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, 黄祥 steve.van...@gmail.com 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





[web2py] Re: password encrypt during insert

2011-04-28 Thread salbefe
it works for me !

Thanks a lot

On 28 abr, 17:02, Stifan Kristi steve.van.chris...@gmail.com wrote:
 thank you so much for your pointer, anthony, the encrypted password is
 without *|encrypted password|None.*
 i've compared with the manual that i put on the register form is same. (same
 password 'a' string)
 but, pardon there is strange behaviour during login, the user that i
 inserted via script couldn't login, but the manual one could login. is there
 anything i missed on my code?
 e.g.
     db.auth_user.bulk_insert([{'first_name' : 'a',
                                'last_name' : 'a',
                                'email' : 'a.a.com',
                                'password' :
 db.auth_user.password.validate('a')[0]}])

 thank you very much before.







 On Thu, Apr 28, 2011 at 9:46 PM, Anthony abasta...@gmail.com wrote:
  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 sal...@gmail.com 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, 黄祥 steve.van...@gmail.com 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


Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread Anthony
On Thursday, April 28, 2011 11:02:18 AM UTC-4, 黄祥 wrote: 

 thank you so much for your pointer, anthony, the encrypted password is 
 without *|encrypted password|None.* 
 i've compared with the manual that i put on the register form is same. 
 (same password 'a' string)
 but, pardon there is strange behaviour during login, the user that i 
 inserted via script couldn't login, but the manual one could login. is there 
 anything i missed on my code?

 
Sorry, not sure about that one.


[web2py] Re: password encrypt during insert

2011-04-28 Thread Massimo Di Pierro
Is it possible that

db.auth_user.requires is not set or it is changed?

On Apr 28, 10:02 am, Stifan Kristi steve.van.chris...@gmail.com
wrote:
 thank you so much for your pointer, anthony, the encrypted password is
 without *|encrypted password|None.*
 i've compared with the manual that i put on the register form is same. (same
 password 'a' string)
 but, pardon there is strange behaviour during login, the user that i
 inserted via script couldn't login, but the manual one could login. is there
 anything i missed on my code?
 e.g.
     db.auth_user.bulk_insert([{'first_name' : 'a',
                                'last_name' : 'a',
                                'email' : 'a.a.com',
                                'password' :
 db.auth_user.password.validate('a')[0]}])

 thank you very much before.







 On Thu, Apr 28, 2011 at 9:46 PM, Anthony abasta...@gmail.com wrote:
  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 sal...@gmail.com 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, 黄祥 steve.van...@gmail.com 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


Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread ron_m
email of a.a.com is not a valid email address according to your code.
I am not sure if there is any validation during login


Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread Stifan Kristi
yes, u right, ron, there is a mistaken on my field value, thanks for show me
my wrong code, it's work right now. thank you all for your pointer.

On Fri, Apr 29, 2011 at 12:10 AM, ron_m ron.mco...@gmail.com wrote:

 email of a.a.com is not a valid email address according to your code.
 I am not sure if there is any validation during login