8.2.10.5.11.11. User¶
- class User(**kwargs)[source]¶
Methods
__delattr__Implement delattr(self, name).
__dir__Default dir() implementation.
__eq__Checks the equality of two UserMixin objects using get_id.
__format__Default object formatter.
__ge__Return self>=value.
__getattribute__Return getattr(self, name).
__getstate__Helper for pickle.
__gt__Return self>value.
__hash__Return hash(self).
A simple constructor that allows initialization from kwargs.
__init_subclass__This method is called when a class is subclassed.
__le__Return self<=value.
__lt__Return self<value.
__ne__Checks the inequality of two UserMixin objects using get_id.
__new____reduce__Helper for pickle.
__reduce_ex__Helper for pickle.
Return repr(self).
__setattr__Implement setattr(self, name, value).
__sizeof__Size of object in memory, in bytes.
__str__Return str(self).
__subclasshook__Abstract classes can override this to customize issubclass().
augment_auth_tokenOverride this to add/modify parts of the auth token.
calc_usernameCome up with the best 'username' based on how the app is configured (via
SECURITY_USER_IDENTITY_ATTRIBUTES).get_auth_tokenConstructs the user's authentication token.
get_idReturns the user identification attribute.
get_redirect_qparamsReturn user info that will be added to redirect query params.
Serialize user object as response payload.
has_permissionReturns True if user has this permission (via a role it has).
has_roleReturns True if the user identifies with the specified role.
tf_send_security_tokenGenerate and send the security code for two-factor.
us_send_security_tokenGenerate and send the security code for unified sign in.
verify_and_update_passwordReturns
Trueif the password is valid for the specified user.verify_auth_tokenOverride this to perform additional verification of contents of auth token.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
Attributes
__abstract____dict____fsa__Internal reference to the extension object.
__weakref__list of weak references to the object
_sa_registryis_activeReturns True if the user is active.
is_anonymousis_authenticatedmetadataregistry- firstname¶
- lastname¶
- avatar¶
- custom_data¶
- settings¶
- get_security_payload()[source]¶
Serialize user object as response payload. Override this to return any/all of the user object in JSON responses. Return a dict.
- __annotations__ = {'__fsa__': 't.ClassVar[SQLAlchemy]', 'active': 'bool', 'confirmed_at': 'datetime | None', 'create_datetime': 'datetime', 'current_login_at': 'datetime', 'current_login_ip': 'str | None', 'email': 'str', 'fs_token_uniquifier': 'str', 'fs_uniquifier': 'str', 'fs_webauthn_user_handle': 'str', 'id': 'int', 'last_login_at': 'datetime', 'last_login_ip': 'str | None', 'login_count': 'int', 'mf_recovery_codes': 'list[str] | None', 'password': 'str | None', 'query': 't.ClassVar[Query]', 'query_class': 't.ClassVar[type[Query]]', 'roles': 'list[RoleMixin]', 'tf_phone_number': 'str | None', 'tf_primary_method': 'str | None', 'tf_totp_secret': 'str | None', 'update_datetime': 'datetime', 'us_phone_number': 'str | None', 'us_totp_secrets': 'str | bytes | None', 'username': 'str | None', 'webauthn': 'list[WebAuthnMixin]'}¶
- __doc__ = None¶
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- __mapper__ = <Mapper at 0x7854e77a0950; User>¶
- __module__ = 'schedula.utils.form.server.security'¶
- __table__ = Table('user', MetaData(), Column('firstname', String(length=255), table=<user>), Column('lastname', String(length=255), table=<user>), Column('avatar', JSON(), table=<user>), Column('custom_data', JSON(), table=<user>), Column('settings', JSON(), table=<user>), Column('fs_webauthn_user_handle', String(length=64), table=<user>), Column('mf_recovery_codes', AsaList(), table=<user>), Column('password', String(length=255), table=<user>), Column('us_phone_number', String(length=128), table=<user>), Column('username', String(length=255), table=<user>), Column('us_totp_secrets', Text(), table=<user>), Column('id', Integer(), table=<user>, primary_key=True, nullable=False), Column('email', String(length=255), table=<user>, nullable=False), Column('active', Boolean(), table=<user>, nullable=False), Column('fs_uniquifier', String(length=64), table=<user>, nullable=False), Column('confirmed_at', DateTime(), table=<user>), Column('last_login_at', DateTime(), table=<user>), Column('current_login_at', DateTime(), table=<user>), Column('last_login_ip', String(length=64), table=<user>), Column('current_login_ip', String(length=64), table=<user>), Column('login_count', Integer(), table=<user>), Column('tf_primary_method', String(length=64), table=<user>), Column('tf_totp_secret', String(length=255), table=<user>), Column('tf_phone_number', String(length=128), table=<user>), Column('create_datetime', DateTime(), table=<user>, nullable=False, server_default=DefaultClause(<sqlalchemy.sql.functions.now at 0x7854e77814d0; now>, for_update=False)), Column('update_datetime', DateTime(), table=<user>, nullable=False, onupdate=CallableColumnDefault(<function naive_utcnow>), server_default=DefaultClause(<sqlalchemy.sql.functions.now at 0x7854e77817d0; now>, for_update=False)), schema=None)¶
- __tablename__ = 'user'¶
- _sa_class_manager = {'active': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'avatar': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'confirmed_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'create_datetime': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'current_login_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'current_login_ip': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'custom_data': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'email': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'firstname': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'fs_uniquifier': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'fs_webauthn_user_handle': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'last_login_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'last_login_ip': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'lastname': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'login_count': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'mf_recovery_codes': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'password': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'roles': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'settings': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tf_phone_number': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tf_primary_method': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tf_totp_secret': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'update_datetime': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'us_phone_number': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'us_totp_secrets': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'username': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}¶
- create_datetime: datetime¶
- current_login_at: datetime¶
- last_login_at: datetime¶
- update_datetime: datetime¶
- query: t.ClassVar[Query]¶
A SQLAlchemy query for a model. Equivalent to
db.session.query(Model). Can be customized per-model by overridingquery_class.Warning
The query interface is considered legacy in SQLAlchemy. Prefer using
session.execute(select())instead.