Skip to content

Class: User

Adam Campbell edited this page Nov 7, 2016 · 13 revisions

Class Definition

The User Class provides functionality required to create, update, and remove Users within the AWS LAMBDA CMS. User.py also provides functionality for fetching data for specific Users, list data for all Users, and Role management associated with Users.


Method Overview

Name Description
login Logs a User into a new session.
logout Logs a User out of their current session.
get_all_users Gets a list of data for all Users.
get_user Gets data about a specific User.
put_user Sets (insert/update) a Blog.
delete_user Deletes an existing User from the CMS.
get_all_roles Gets a list of data for all Roles.
get_role Gets data about a specific Role.
put_role Sets (insert/update) a Role.
delete_role Deletes an existing Role from the CMS.

Method Detail

login

Logs an existing User into a session by creating and storing an active Token for the User. Returns Token in the form of a Set-Cookie header, which is then logged into the Users machine.

Parameters
email - The email address for the existing User.
password - The password for the existing User.
token - Needs removing
user-table - The CMS-specific table name for the User table.
token-table - The CMS-specific table name for the Token table.

Returns
Message - Successfully logged in
Cookie - Returns Set-Cookie header containing the active Token for the User. Cookie has a 24 hour lifetime before expiring.

Throws
invalidEmail - The email address provided does not exist.
userHasNoRole - The User does not have a Role assigned to themselves.
userHasNoPassword - The User does not have a password.
invalidPassword - The password provided does not match the password stored.
Botocore Exception - Refer to Botocore documentation


logout

Logs an existing User out of their current session by deleting their active Token in the Token table.

Parameters
token - The Token string associated with a User. token-table - The CMS-specific table name for the Token table.

Returns
message - Successfully logged out

Throws
Botocore Exception - Refer to Botocore documentation


get_all_users

Retrieves a data set of information regarding the existing Users from the User table.

Parameters
user-table - The CMS-specific table name for the User table.

Returns
Message - Successfully retrieved User data Data - A data set of information for existing Users.

Throws
noUsers - There are no existing Users within the User table. Botocore Exception - Refer to Botocore documentation.


get_user

Retrieves a data set of information for a specific User from the User table.

Parameters
email - The email address of the User you want to get information for.
user-table - The CMS-specific table name for the User table.

Returns
Message - Successfully retrieved User data.
Data - A data set of information for the specific User.

Throws
InvalidEmail - The email address provided does not match any existing User.
Botocore Exception - Refer to Botocore documentation.


put_user

Inserts a User into the User table. The password provided goes through a pbkdf2_sha256 hashing process of 10,000 rounds. This can be either inserting a new User, or updating an existing User.

Parameters
email - The email address of the User.
username - The username of the User.
password - The password of the User.
role-table - The CMS-specific table name for the Role table.
user-table - The CMS-specific table name for the User table.

Returns
Message - Successfully put new User.
Data - A data set of information for the inserted User.

Throws
Botocore Exception - Refer to Botocore documentation


delete_user

Deletes an existing User from the User table.

Parameters
email - The email address of the User to delete.
user-table - The CMS-specific table name for the User table.

Returns
Message - Successfully deleted User.

Throws
Botocore Exception - Refer to Botocore documentation


get_all_roles

Retrieves a data set of information regarding the existing Roles from the Role table.

Parameters
role-table - The CMS-specific table name for the Role table.

Returns
Message - Successfully retrieved Role data Data - A data set of information for existing Roles.

Throws
noRoles - There are no existing Roles within the Role table.
Botocore Exception - Refer to Botocore documentation


get_role

Retrieves a data set of information for a specific Role from the Role table.

Parameters
role_name - The role name of the Role you want to get information for.
role-table - The CMS-specific table name for the Role table.

Returns
Message - Successfully retrieved Role data.
Data - A data set of information for the specific Role.

Throws
InvalidRoleName - The role name provided does not match any existing Role.
Botocore Exception - Refer to Botocore documentation


put_role

Inserts a Role into the Role table. This can be either a new Role, or updating an existing Role.

Parameters
role_name - The role name of the Role.
permissions - The permissions associated with the new Role.
role-table - The CMS-specific table name for the Role table.

Returns
Message - Successfully put Role.
Data - A data set of information for the inserted Role.

Throws
Botocore Exception - To be completed


delete_role

Deletes an existing Role from the Role table.

Parameters
role_name - The role name of the Role to delete.
role-table - The CMS-specific table name for the Role table.

Returns
Message - Successfully deleted Role.

Throws
Botocore Exception - Refer to Botocore documentation


Clone this wiki locally