Trying to set up a new user via script, and as usual it isn't going 
smoothly.  web2py 2.15.4, fronted by nginx

Using adduser script, which I think I got from this group (or maybe from a 
pointer Massimo provided):


"""

import gluon.tools

auth = session.auth
db   = session.db
new_user = auth.register_bare(email='[email protected]', 
password='4mark2easy')
print (new_user)
if new_user:
  new_user.update_record(registration_key='') # This approves the 
registration - can be done later
db.commit()
print (other_stuff_from_auth)


This successfully adds a new user, but when  the new user tries to login, 
more times than not the result is "invalid login".  (The login form is the 
out-of-the-box one via default/user.)  Sometimes, it works on the first try.

Q1:  Why does the login often fail?

The script doesn't update an existing user; register_bare() and its 
underwiring check for newness (as in !IS_IN_DB()), so it doesn't work as a 
reset password tool.  The reset-password-email technique doesn't work here, 
because not all of these users have valid email addresses.  I can use port 
forwarding to use appadmin, but the server command line is easier in this 
setup.

Q2:  Is there an easy way to script resetting a user's password?  

Some of these accounts should only be used on a short-term basis.  I can 
manually reset the password, or delete the user, but I'd like a failsafe 
mechanism in case I forget:

Q3:  Is there a way to automatically expire a password?

I have a function with the @request.restful() decorator; it should require 
login as well.

Q4: Can I use @auth.requires_login() with @request.restful()


Thanks.

Dave
/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to