NO. You cannot use password=IS_CRYPT()(passwd)[0])
You must use password=db.auth_user.password.requires[0](passwd)[0]) the reason is that IS_CRYPT() by default uses MD5 while if you pass a key IS_CRYPT(key='sha521:blabla') is uses better algorithms (for example hmac+sha512). So to encrypt the password you have to use the same IS_CRYPT(key='...') that you used when defining the model. When you create a new app from admin, auth uses hmac+sha512. Massimo On Apr 21, 7:05 pm, rohfle <[email protected]> wrote: > You probably need to 'crypt' the password before inserting it into the > database. > > This can be done using something like: > > pw_hasher = IS_CRYPT() > ticket_master = db.auth_user.insert(first_name=fname, > last_name=lname, > email=maile, > password=pw_hasher(passwd)) > > The form based user registration does this automatically as part of > validation, but since you are inserting a record manually, these > validation steps are not executed to the best of my knowledge. > > Regards, > R > > On Apr 22, 9:32 am, Patrick <[email protected]> wrote: > > > I have been learning web2py and decided to create a simple ticket > > system. Thus far I've been able to read the book/documentation or look > > at others code and been able to hack my way through most issues. > > However in my situation I need to have a default user created for > > default administrative purposes, such as adding other admin users (I > > know this isn't the best way to accomplish this but I'm learning... > > advice, suggestions always welcome). > > > I've tried something similar to this post "http://groups.google.com/ > > group/web2py/browse_thread/thread/39f2d63f7024bbfb/2da45ae0132fe8fc? > > lnk=gst&q=auto+users#2da45ae0132fe8fc", but I can't login as the user > > because it says invalid login. > > > I believe this is due to when I set the default password. If I login > > appadmin and change the password and then try to login it works. So > > I'm messing up on the password creation part. Here is the code for my > > z_defuser.py: > > > fname='ticket' > > lname='master' > > maile='[email protected]' > > passwd='tmaster09!' > > > # Check to see if the user exists first. > > # If the user does do nothing, else create the new user. > > rows = db(db.auth_user.email == maile).select() > > if rows: > > pass > > else: > > ticket_master = db.auth_user.insert(first_name=fname, > > last_name=lname, > > email=maile, > > password=passwd) > > > P.S. > > Any suggestions/advice are welcome. Thank you.

