Fullstack Fruit & Veg Shop: A web application developed with HTML, CSS, and JavaScript for the frontend, and Django for the backend. Features include user authentication, a product catalogue, shopping cart functionality, and order management. and much more
Implemented a login feature allowing users to authenticate using their credentials. The feature utilises fetch to
verify user credentials. It displays appropriate messages if credentials are invalid, or if the user account is banned or inactive.
auth.js
Refactored logic: Extracted the data-fetching logic from handleRegisterFormSubmit and placed it into a reusable
function called processRegistrationForm.
Added getEntries: A function to extract data from the form and pass it to processRegistrationForm.
Introduced setButtonState: A function to manage the button state during the fetch process, e.g., disabling
the button to prevent multiple queries and showing status messages.
Added handleLoginFormSubmit: A function to manage user login requests, displaying messages based on whether the user
is banned, active, or logs in successfully.
views.py in authentication/ app
Created user_login: A view function that allows the frontend to submit user credentials and checks their validity.
It responds with validation results.
Updated navigation bar: The navigation now displays user status as follows:
Superuser
Admin
Regular user
Logged-in users have access to a dropdown account menu.
Non-logged-in users see only 'register' and 'login' options.
Secured accounts page: Restricted access to configuration settings such as adding products to superusers and admins only.
Implemented a redirect: Prevents unauthenticated users from accessing the accounts page, redirecting them to the home page.
Currently, this redirect is only applied to the accounts page; other protected pages will be secured in a future update.
TODO:
Add logout functionality
Prevent unauthorised users from accessing protected pages
Login Feature
fetch
to verify user credentials. It displays appropriate messages if credentials are invalid, or if the user account is banned or inactive.auth.js
handleRegisterFormSubmit
and placed it into a reusable function calledprocessRegistrationForm
.getEntries
: A function to extract data from the form and pass it toprocessRegistrationForm
.setButtonState
: A function to manage the button state during thefetch
process, e.g., disabling the button to prevent multiple queries and showing status messages.handleLoginFormSubmit
: A function to manage user login requests, displaying messages based on whether the user is banned, active, or logs in successfully.views.py
inauthentication/
appCreated
user_login
: A view function that allows the frontend to submit user credentials and checks their validity. It responds with validation results.Updated navigation bar: The navigation now displays user status as follows:
Secured accounts page: Restricted access to configuration settings such as adding products to superusers and admins only.
Implemented a redirect: Prevents unauthenticated users from accessing the accounts page, redirecting them to the home page. Currently, this redirect is only applied to the accounts page; other protected pages will be secured in a future update.
TODO: