Open GitMorin opened 4 years ago
Using a CustomUserManager, you can over ride the default invitation view which is here:
and add the roles_required decorator
class CustomUserManager(UserManager):
@login_required
@roles_required('specialrole')
def invite_user_view(self):
""" Allows users to send invitations to register an account. """
<rest of original code>
@carissableker Thanks 😊, I implemented your solution and it worked like magic. and here is how I did it
# Customize Flask-User
class CustomUserManager(UserManager):
# Making user invitation limited to admin role only
@roles_required('admin')
def invite_user_view(self):
return super().invite_user_view()
# Setup Flask-User and specify the User data-model
user_manager = CustomUserManager(app, db, User)
Is there a way I can overwrite the user_invite functionality so only users with admin role can access the route? I dont want anyone to be able to invite new users.