Need help with login/reset password using Flask and HTML

Hello, I am have two issues with my web app. Right now I am trying to get login and reset password to work properly in this small project so that I can implement it into my main web app afterwards. It’s just simple project with an index page, and you can login, logout, access an admin page and reset password. Before anyone mentions it, I am not using a database to store the user because the teacher wants it in a CSV file. 

GitHub Project:

Here are the two issues:

  1. When clicking Submit on the Forgot password page, it redirects me to random pages…Sometimes it’s /login_success and sometimes it’s /admin from what I’ve seen so far. It should be going to /forgot_success. The password in the CSV file is getting changed though.

  2. Ever since I built the Forgot password page and used it to change the value in the CSV file, my Login page doesn’t work properly anymore. When inputting the wrong password/user combination, it should flash ‘Incorrect user/pass’ but instead it gives me this error:

File “C:\Users\MobileKlinik\PycharmProjects\untitled1\”, line 45, in check_password
if username == user[0] and password == user[1]:
IndexError: list index out of range

Again, this only started happening AFTER making the Forgot password page and using it to change the password in the CSV file. Very strange…

If anyone can help me fix these issues, I’d greatly appreciate it. Thanks!

Hey @stunt296,

Is there any reason why you don’t use a database?

You can use sqlalchemy and SQLite. Then you don’t need to set up a DB server first. 

Greets :slight_smile:

Hey @stunt296,

something I want to add: 

If you still want to use a CSV file and you still have this problem. I will help you. 

me too using csv, when I started making multiple apps I wanted to create db for each app inside the app directory, so after searching for method to handle this problem I couldn’t , If you please help me

CSV is good for local use but, I do not recommend it. The best way is to create a database (locally or externally) and then export the data to CSV. If you want to see more feel free to check out

hope this helps!