Write a script, similar to sqlite1.py that creates a SQLite database and a table to store user data. The table should contain:
- A username (TEXT, NOT NULL)
- Password hash (TEXT, NOT NULL)
The table should also enforce that usernames are unique.
Write methods
- Create the table
- Insert a user into the table
- Retrieve a user, based on his name
Update the login example to use the database you created. Further extend the example to allow signup.
Extend your application with user roles, e.g. admin and user.
You need to:
- Extend the user table to contain a user
role - Extend the login and logout, to store/remove the current user role in the session
- Create an additional route, e.g.
/adminthat is only accessible to admin users. - If a non admin user accesses this route (e.g. typing it into the address field) the server should return a 403 error.