Forums

create separate logins for supplier and customers using flask-security

Hi,

I have a Flask app with Flask Security. There are two kinds os users who will use my app. suppliers and customers...

At the moment, I have added an option in /register form for the user to select what type of account they want. But I believe there's a higher degree of human error this way.

How do I implement two different register pages using Flask-security or is there any other way?

Thanks

You could customize your registration view (and have two views potentially with different forms etc)

Thanks @conrad. Sorry for the delay. I went through the docs but couldnt get my head around on how exactly to do that... I see that Flask-security has SECURITY_REGISTER_USER_TEMPLATE where you can set it to a view you want. But since registration is handled internally by flask-security how can you link the form to that ?

Maybe you can add a parameter to the view so the template renders differently or something like that. This is probably a question that the people that wrote flask-security can answer better than we can.

Thanks Glenn,

After some research , I followed this SO post

https://stackoverflow.com/questions/35660625/error-extending-registerform-in-flask-security?noredirect=1&lq=1

I am Extending the register form by including a hiddenfield to identify the role of a user. I have "/user/supplier" and "/user/customer" . So I detect if the url if either and include that role in the hidden field in the register view. The SO post says a custom function. I am not getting my head around how to call that from the form or how to pass my form to that function...?

Are you sure that's the right link? I don't see any references to custom functions in there...