You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello i would like to know if it's possible to change default flask-user flash messages.
For example the ones in "user_manager__views.py"
When i use @login_required it redirects the user to the login page and shows this message "You must be signed in to access {here_the_url}."
What can i do if i want to show another message? Is it possible?
The text was updated successfully, but these errors were encountered:
Use a custom user manager. You will be able to change the function used for the view below is an example that should be enough to give you an idea on where to start. Haven't tested it but should be able to do the job.
fromflask_user.user_managerimportUserManagerfromflaskimportredirect, flashclassCustomUserManager(UserManager):
defunauthenticated_view(self):
""" Prepare a Flash message and redirect to USER_UNAUTHENTICATED_ENDPOINT"""# Prepare Flash messageurl=request.urlflash(_("You must be signed in to access '%(url)s'.", url=url), 'error') # Insert your own message# Redirect to USER_UNAUTHENTICATED_ENDPOINTsafe_next_url=self.make_safe_url(url)
returnredirect(self._endpoint_url(self.USER_UNAUTHENTICATED_ENDPOINT)+'?next='+quote(safe_next_url))
user_manager=CustomUserManager(app, db, User)
Hello i would like to know if it's possible to change default flask-user flash messages.
For example the ones in "user_manager__views.py"
When i use @login_required it redirects the user to the login page and shows this message "You must be signed in to access {here_the_url}."
What can i do if i want to show another message? Is it possible?
The text was updated successfully, but these errors were encountered: