UserManager Utility methods

Below is a complete list of Flask-User utility methods.

| The UserManager__Utils class mixes into the UserManager class.
| Mixins allow for maintaining code and docs across several files.
class UserManager__Utils

Flask-User utility methods.

call_or_get(function_or_property)
Calls function_or_property if it’s a function.
Gets function_or_property otherwise.

In Flask-Login 0.2 is_authenticated and is_active were implemented as functions, while in 0.3+ they are implemented as properties.

Example:

if self.call_or_get(current_user.is_authenticated):
    pass
email_is_available(new_email)

Check if new_email is available.

Returns True if new_email does not exist or belongs to the current user.
Return False otherwise.
generate_token(*args)

Convenience method that calls self.token_manager.generate_token(*args).

hash_password(password)

Convenience method that calls self.password_manager.hash_password(password).

make_safe_url(url)

Makes a URL safe by removing optional hostname and port.

Example

make_safe_url('https://hostname:80/path1/path2?q1=v1&q2=v2#fragment')
returns '/path1/path2?q1=v1&q2=v2#fragment'

Override this method if you need to allow a list of safe hostnames.

prepare_domain_translations()

Set domain_translations for current request context.

verify_password(password, password_hash)

Convenience method that calls self.password_manager.verify_password(password, password_hash).

verify_token(token, expiration_in_seconds=None)

Convenience method that calls self.token_manager.verify_token(token, expiration_in_seconds).