newauth.api¶
Alex Gaynor will kill me
-
class
newauth.api.
UserBase
(*args, **kwargs)¶ Base User class
Primary key can be defined in sub classes. This class makes no assumptions about the format of the primary key. Only a pk property (the primary key might be something other than id) and the methods implemented below can be assumed are present.
This class also makes no assumptions about underlying implementations like what fields are on the User object or the table name.
-
get_display_name
()¶ Name for display. Usually a username or something similar. Usually used for public pages. This method should return a unicode object.
-
get_real_name
()¶ The user’s real name or closest approximation. Usually used for private pages etc.
-
is_authenticated
()¶ Returns whether a user is authenticated or not. The default is for this method to always return true for subclasses of UserBase and False for subclasses of AnonymousUserBase
-
-
class
newauth.api.
AnonymousUserBase
¶ A simple anonymous user.
-
class
newauth.api.
BasicUserManager
¶ A default manager that can be used with models that subclass BasicUserBase.
-
class
newauth.api.
BasicUserBase
(*args, **kwargs)¶ A basic user that is authenticated with a username and password.
This class can be subclassed when using a simple username password auth system.
-
check_password
(raw_password)¶ Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes.
-
get_display_name
()¶ Name for display. Usually a username or something similar. Usually used for public pages. This method should return a unicode object.
-
set_password
(raw_password)¶ Sets the password of the user. Alorithm
-
-
class
newauth.api.
BasicAnonymousUser
¶
-
newauth.api.
authenticate
(_backend_name=None, **credentials)¶ Authenticate a user with using the available auth backends. If a _backend_name is provided require authentication via the backend with that name.
If the given credentials are valid, return a User object as provided by the backend.
-
newauth.api.
login
(request, user, backend_name=None)¶ Log the user in given the request object. This will save any data needed to auth the user (user id and backend name) using the auth session storage (not necessarily django sessions).
-
newauth.api.
logout
(request)¶ Logs the user out. This will clear the user’s login session data from the auth session storage.