How to programmatically insert a row that includes email and and hashed password into auth_user in web2py? Something like the flask-compatible code below.
def find_or_create_user(username, email, password, role=None):
""" Find existing user or create new user """
user = User.query.filter(User.email == email).first()
if not user:
user = User(username=username,
email=email,
password=current_app.user_manager.hash_password(password),
is_enabled=True,
confirmed_at=datetime.datetime.utcnow())
if role:
user.roles.append(role)
db.session.add(user)
return user
The material line is:
db.auth_user.validate_and_insert(email=email, password=password...)