Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Python program: Create a login and menu to a company intranet system tha

ID: 3880972 • Letter: W

Question

Write a Python program: Create a login and menu to a company intranet system that requires users (employees) to enter a username and password in order to view a menu of options (such as Time Reporting, Accounting, IT Helpdesk, Engineering Documents, etc. ).

Technical requirements:

Plaintext usernames/passwords/access level stored in a csv (or text) file

Create three different access levels (roles for different users). For example, User A should have access to all menu items ('admin' access), while User B has limited access (no Accounting or Engineering Documents), etc.

Once logged in the user should be able to select different menu options with a number input (for example, "press 1 for the Time Reporting area", "press 2 for the Accounting area", etc.)

When a user accesses a menu area they have access to, a simple message similar to 'You have now accessed the accounting application' is sufficient to indicate a successful demonstration of the access control (no need to build out any actual accounting functionality). Likewise, if a user does not have the appropriate access level to view a menu area, the program should display a 'You are not authorized to access this area.' message and provide an option to return them to the main menu.

Explanation / Answer

#!usr/bin/python

name = input('Enter user: ')
password = input('Enter password: ')

file = open("user.csv","r");
access = ""
found = 0
for line in file:
    if (line.split(',')[0] == name):
       found = 1
       if (line.split(',')[1] == password):
           access = line.split(',')[2]
       else:
           print ("Incorrect password")

file.close()

access = access.replace(" ","")
if found == 0:
   print('Incorrect user')
else:
   choice = -1
   while choice != 5:
         print('1.Time Reporting')
         print('2.Accounting')
         print('3.IT Helpdesk')
         print('4.Engineering Documents')
         print('5.Quit')
         choice = int(input("Enter your choice"))
         if choice == 1:
            if access == "normal" or access == "admin":
               print("You have accessed Time Reporting application")
         if choice == 2:
            if access == "admin":
               print("You have accessed Time Accounting application")
            else:
               print("You are not authorized to access Accounting")
         if choice == 3:
            if access == "normal" or access == "admin":
               print("You have accessed IT Helpdesk application")
         if choice == 4:
            if access == "admin":
               print("You have accessed Engineering Documents application")
            else:
               print("You are not authorized to access Engineering Documents")

user.csv:

user1,user1,normal      (format: username, password, access)
admin,admin,admin

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote