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 <arcaneli...@gmail.com> 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='tmas...@example.com'
> 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.

Reply via email to