Reputation: 153
I want to disable normal registering in my web2py app and only allow certain "admin" users to create new users. I know how to disable registering, but I don't know how to make an interface for users to create other users. What I want is a page similar to [app]/default/user/register
or [app]/appadmin/insert/db/auth_user
but accessible while you are logged in and only to "admin" users. I could make a simple HTML form, but then I would lose all the important validators and such the normal registering has, and more importantly, I would needlessly repeat someone else's work and not do it the "web2py" way.
(To more elaborate, my groups have certain "group_master" users, saved in "group_master" table in database. And I want only group_masters to access the create_user page, and after the user is created, it will automatically join the group_master's group. I think I know how to deal with the group membership hassle in code, but I need help to create the interface.)
Upvotes: 0
Views: 679
Reputation: 25536
To get the user input, you can either create a custom form or use something like SQLFORM(db.auth_user).process(dbio=False)
(the dbio=False
prevents the automatic creation of a database record upon submission of the form). You can then register the user via:
auth.register_bare(email=request.vars.email, password=request.vars.password)
Upvotes: 1