Users
Use the Users class when setting up your users in hyfiles
like this:
(setv users
(Users
[{"admin" ;; username
"password" ;; password
:nickname "admin"} ;; extra optional data
{"user1" "password1"
:attribute "blah"
:nickname "mynickname"
:email "admin@example.com"}]))
Create the Users object by giving it a list where
each list item is a dictionary
with user data. Each user entry is required to have at least on
key:value pair which is assumed to be username:password and
can therefore be accessed by the Variable Plugin as (Variable "username") and
(Variable "password") respectively.
To use the optional user data, do the same but replace
username/password with the symbol name you specified earlier, for
example (Variable "nickname") will return admin if the first
user is active and mynickname if the second one is.
- class Users(users=None, active_user='DEFAULT')[source]
Class holding all the users of the application.
Users inherits from
DataStructure, and contains the users set up in hyfiles. Each user is anUserobject. The data from aUsersobject can be accessed same way like from theDataStore.
The Users class inherits from DataStore where each element is a User
class containing data about a single user:
- class User(username=None, password=None, **kwargs)[source]
Class holding user related information.
Userobjects are created inside theUsers. EachUserobject contains at least theusernameand thepassword. Every time aPlugingenerates an output, it is saved in theUserobject. If thePluginis aCookieor aHeader, the output will be stored in the thecookiesandheadersattributes respectively. Otherwise they’ll be saved insidedata.- username
A string containing the user’s email or username used to log in.
- password
A string containing the user’s password.
- cookies
A
CookieStoreobject containing all of the collected cookies for this user. TheCookieplugin only writes here.
- headers
A
HeaderStoreobject containing all of the collected headers for this user. TheHeaderplugin only writes here.
- __init__(username=None, password=None, **kwargs)[source]
Initializes a
Userobject.Creates an object for easy access to user specific information. It’s used to store the
username,password,cookies,headers, and otherdataextracted from thePluginobjects.- Parameters
username (
Optional[str]) – A string with the username used for the login process.password (
Optional[str]) – A string with the password used for the login process.**kwargs (
Dict[str,str]) – A dictionary with additional data about the user.
- set_cookie(cookie)[source]
Sets the
cookiesfor the user.Given a
Cookieobject, update the user’scookiesattribute to include thisCookie'svalue.
- set_cookies_from_dict(data)[source]
Set user’s
cookiesfrom a dictionary.Given a dictionary of cookie values as strings, convert them to
Cookieobjects, and load them in theUserobject respectively.- Parameters
data (
Dict[str,str]) – A dictionary of strings corresponding to cookie keys and values.- Return type
None
- set_header(header)[source]
Sets the
headersfor the user.Given a
Headerobject, update the user’sheadersattribute to include this header value.
- set_headers_from_dict(data)[source]
Set user’s
headersfrom a dictionary.Given a dictionary of header values as strings, convert them to
Headerobjects, and load them in theUserobject respectively.- Parameters
data (
Dict[str,str]) – A dictionary of strings corresponding to header keys and values.- Return type
None
- set_data(data)[source]
Sets the
datafor the user.Given a
Plugin, update the user’sdataattribute to include this data.