Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 8 Next »

Authentication

create user(email, username, password):

// Check email if email is valid

validate_email(email)

 

// check if username is invalid

If len(username) > 100 and len(username) < 5:

Input error

// check if password is invalid

If len(password) > 100 and len(password) < 5:

Input error

 

Hash password

 

// check for duplicate email

If other user has same email:

            Input error

 

Create new user

Add user to database

Return success = True

 

create_session(username, password):

hash password

Find user in database

If user not found:

            Input error 

Create new session

Add session to database

Create token

Return token

remove_session(token):

session = load_token(token)

Remove session from database

Return {}

 

check_token(token):

            Session = load_token(token)

            Return session.userId
load_token(token):

try:

decode token

 except base exception:

access error

find session in database

 

if session not found:

            Input error

           

Return session

Communication report

communication_report(error_codes, time_sent):

communication report  = {

check error booleans against error codes

}

for error code in error codes:

include readable message

return communication report

 

Email system

validate_email(email):

if email is in correct format:

            return True

else:

            return False

 

send_email(xml, timer_start):

error_codes = []

contacts = customerContact(xml)

 

if xml does not exist or is empty:

            append 1 to error_codes

 

if xml size > 10485760:

            append 2 to error_codes

 

if not validate_email(contacts[‘cust_email’):

append 3 to error_codes

 

if any error codes:

            raise Input error

create email

try:

            send mail

 

return communication_report(error_codes, timer_start) , contacts[‘cust_email’]

 

Health check

healthCheckInfo():

upTime = current time – time server started 

alive = True

find call_num in database

 

return {'alive’: alive, 'serverUpTime': upTime, 'numTransactions': call_num, 'currentVersion' : "Version 1 release"}

 

Log 

log_health_check():

create new health check call

add call to database

 

log_send_invoice(user_id, email_address):

create new send invoice call

add call to database

Ubl Extractor 

customerContact(xml):

turn xml into string invoice

find customer in xml

find customer info in customer

find contact info from the customer info

 

find seller in xml

find seller info in customer

find contact info from the seller info

 

add customer contact info and seller info to dictionary

 

return contact dictionary

 

  • No labels