pryv.user

This module defines users related functions. In particular, it defines the functions used to authenticate a user.

class pryv.user.User(name)

Bases: object

This class defines a user.

__init__(name)

Creates a new instance of a user.

Parameters:name (str) – The name of the user.
pryv.user.authenticate(username, password)

Authenticates the user with the given name and password.

Parameters:
  • username (str) – The name of the user.
  • password (str) – The password.
Returns:

True if the pair user name / password is valid; False otherwise.

Return type:

bool

pryv.user.count()

Counts the number of configured users.

Returns:The number of users.
Return type:int
pryv.user.create(username, password)

Creates a new user and returns it.

Parameters:
  • username (str) – The name of the user.
  • password (str) – The password of the user.
Returns:

The instance of the user.

Return type:

User

pryv.user.find(username)

Finds the user with the given name.

Parameters:username (str) – The name of the user.
Returns:The instance of the user if found; None otherwise.
Return type:User
pryv.user.get_current()

Gets the current logged in user.

Warning

This function works only in a Flask environment, with an already existing session.

Returns:The current logged in user or None.
Return type:User or None