Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create multiple user registration forms with flask-user #192

Open
gauravdce opened this issue Nov 6, 2017 · 1 comment
Open

How to create multiple user registration forms with flask-user #192

gauravdce opened this issue Nov 6, 2017 · 1 comment
Labels

Comments

@gauravdce
Copy link

Hello
I understand that flask-user allows users with various roles to login. Based on the different roles that are available to users, each user can access routes that are available to that user and role.
However, I am trying to set up multiple registration pages for each user-role.

E.g. users with admin role have one signup page which asks for a lot of information up front , whereas users with regular role will have a simplified signup page just asking for basic details.
How can this be achieved using flask-user.
One good example would be Employers and Candidates on a job portal. How can we have 2 different forms - one for employers to sign up and another one for candidate sign up .
Both the employers and candidates will go into the users table - but when their individual registration forms are filled out - they will have different roles - in the user-roles table ?

Thanks

@lingthio
Copy link
Owner

lingthio commented Apr 19, 2018

I tend to ask as little info as possible for people to sign up (to avoid users bailing because it asks for too much info). Then, on the first time they log in, I ask for the required additional info.

To do this, I present them with the same (short) register form.

Then in an @app.before_request function:

  • I check the user's role
  • Check if required info has been supplied
  • If not: Present a different UserProfile form for each role
  • Have required fields in each form, so that a user must fill those fields in before they can continue to use the website.

If this doesn't work for you, you can offer regular users with the standard Flask-User register form.
For Admin users you'll need to add your own register_admin() view function that copies Flask-User's register() function and supply your own custom RegisterAdminForm to that view.

For v1.0:
https://github.com/lingthio/Flask-User/blob/master/flask_user/user_manager__views.py#L423

For v0.6:
https://github.com/lingthio/Flask-User/blob/v0.6/flask_user/views.py#L323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants