user.models.user

Classes

SessionDict

dict() -> new empty dictionary

User

Defines a generic user.

Module Contents

class user.models.user.SessionDict[source]

Bases: typing_extensions.TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

address: str | None[source]
timestamp: str[source]
agent: str | None[source]
class user.models.user.User[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.TimestampMixin, onegov.search.ORMSearchable

Defines a generic user.

__tablename__ = 'users'[source]
type: sqlalchemy.Column[str][source]
__mapper_args__[source]
es_properties[source]

Returns the type mapping of this model. Each property in the mapping will be read from the model instance.

The returned object needs to be a dict or an object that provides a to_dict method.

Internally, onegov.search stores differing languages in different indices. It does this automatically through langauge detection, or by manually specifying a language.

Note that objects with multiple languages are not supported (each object is supposed to have exactly one language).

Onegov.search will automatically insert the right analyzer for types like these.

There’s currently only limited support for properties here, namely objects and nested mappings do not work! This is going to be added in the future though.

es_public = False[source]

Returns True if the model is available to be found by the public. If false, only editors/admins will see this object in the search results.

property es_suggestion: tuple[str, str][source]

Returns suggest-as-you-type value of the document. The field used for this property should also be indexed, or the suggestion will lead to nowhere.

If a single string is returned, the completion input equals the completion output. (My Title -> My Title)

If an array of strings is returned, all values are possible inputs and the first value is the output. (My Title/Title My -> My Title)

property userprofile: list[str][source]
id: sqlalchemy.Column[uuid.UUID][source]
username: sqlalchemy.Column[str][source]
password_hash: sqlalchemy.Column[str][source]
role: sqlalchemy.Column[str][source]
group_id: sqlalchemy.Column[uuid.UUID | None][source]
group: sqlalchemy.orm.relationship[onegov.user.models.group.UserGroup | None][source]
realname: sqlalchemy.Column[str | None][source]
data: sqlalchemy.Column[dict[str, Any]][source]
second_factor: sqlalchemy.Column[dict[str, Any] | None][source]
source: sqlalchemy.Column[str | None][source]
source_id: sqlalchemy.Column[str | None][source]
active: sqlalchemy.Column[bool][source]
signup_token: sqlalchemy.Column[str | None][source]
__table_args__[source]
role_mappings: sqlalchemy.orm.relationship[onegov.core.types.AppenderQuery[onegov.user.RoleMapping]][source]
title: sqlalchemy.Column[str][source]
is_matching_password(password: str) bool[source]

Returns True if the given password (cleartext) matches the stored password hash.

classmethod get_initials(username: str, realname: str | None = None) str[source]

Takes the name and returns initials which are at most two characters wide.

Examples:

admin => A nathan.drake@example.org => ND Victor Sullivan => VS Charles Montgomery Burns => CB

property initials: str[source]
property has_yubikey: bool[source]
property yubikey: str | None[source]
property yubikey_serial: int | None[source]

Returns the yubikey serial of the yubikey associated with this user (if any).

property mtan_phone_number: str | None[source]
sessions: onegov.core.orm.mixins.dict_property[dict[str, SessionDict] | None][source]
tags: onegov.core.orm.mixins.dict_property[list[str] | None][source]
phone_number: onegov.core.orm.mixins.dict_property[str | None][source]
cleanup_sessions(app: onegov.core.framework.Framework) None[source]

Removes stored sessions not valid anymore.

save_current_session(request: onegov.core.request.CoreRequest) None[source]

Stores the current browser session.

remove_current_session(request: onegov.core.request.CoreRequest) None[source]

Removes the current browser session.

logout_all_sessions(app: onegov.core.framework.Framework) int[source]

Terminates all open browser sessions.