models¶
Models needed for registration, and user servicing.
- class pyramid_fullauth.models.User(*args, **kwargs)[source]¶
Bases:
UserPasswordMixin
,UserEmailMixin
,Base
User object.
Switch possible email and new_email kwarg into new column attribute names.
- delete()[source]¶
Perform soft delete action. along with checking if it’s super admin, or not.
- Rises pyramid_fullauth.exceptions.DeleteException:
if you try to delete last super admin.
Note
You should use this method to delete users
- email_change_key¶
- property is_active¶
Check if user is active.
- Returns:
Returns False if user account is not active (or deleted).
- Return type:
- password¶
password field
- reset_key¶
reset key field
- validate_is_admin(_, value)[source]¶
Validate is_admin value, we forbid the deletion of the last superadmin.
Note
More about simple validators: http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#simple-validators
- Raises:
AttributeError – Information about an error
- class pyramid_fullauth.models.Group(**kwargs)[source]¶
User group object.
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.
- class pyramid_fullauth.models.AuthenticationProvider(**kwargs)[source]¶
Model to store authentication methods for different providers.
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.
models.mixins¶
Mixin’s main module.
- class pyramid_fullauth.models.mixins.UserPasswordMixin[source]¶
Authentication field definition along with appropriate methods.
- password = Column(None, Unicode(length=128), table=None, nullable=False)¶
password field
- _hash_algorithm = Column('hash_algorithm', Enum('sha512', 'shake_128', 'sha3_256', 'shake_256', 'md5', 'sha1', 'sha224', 'sha384', 'sha256', 'blake2s', 'blake2b', 'sha3_384', 'sha3_512', 'sha3_224', name='hash_algorithms_enum'), table=None, nullable=False, default=ScalarElementColumnDefault('sha256'))¶
hash_algorithm field
- _salt = Column('salt', Unicode(length=128), table=None, nullable=False)¶
salt field
- reset_key = Column(None, String(length=255), table=None)¶
reset key field
- password_validator(_, password)[source]¶
Validate password.
Password validator keeps new password hashed. Rises Value error on empty password
- Parameters:
- Returns:
hashed and salted password
- Return type:
- Raises:
pyramid_fullauth.exceptions.EmptyError
Note
If you’re using this Mixin on your own User object, don’t forget to add a listener as well, like that:
from sqlalchemy.event import listen listen(User.password, 'set', User.password_listener, retval=True)
Note
For more information on Attribute Events in sqlalchemy see:
sqlalchemy.orm.events.AttributeEvents.set()
- class pyramid_fullauth.models.mixins.UserEmailMixin(*args, **kwargs)[source]¶
User email fields and functionality.
Switch possible email and new_email kwarg into new column attribute names.
- email¶
Email field comparator.
- new_email¶
Email field comparator.
- email_change_key = Column(None, String(length=255), table=None)¶
- change_email()[source]¶
Change email after activation.
We don’t clear new email field because of validator of email which won’t allow to None value.
- set_new_email(email_new)[source]¶
Set new email and generate new email change hash.
- Parameters:
email_new (str) – email address
- Returns:
generated email_change_key
- Trype:
str
- validate_email(_, address)[source]¶
Validate email addresses.
Note
See pyramid docs about simple validators
- Parameters:
- Raises:
models.extensions¶
CaseInsensitive comparator for sqlalchemy models.