User Login with Flask_Login - Flask Fridays #22

preview_player
Показать описание
In this video I'll show you how to set up user Login with Flask_Login and Python.

We'll start out adding a Username field to our Users Table. After we migrate the database, we'll update the web forms to handle username.

Then we'll install and set up Flask_login that will handle logging in, logging out, sessions, and all the good things.

We'll also create a user dashboard that will only appear if a user is logged in.

#flask #codemy #JohnElder

Timecodes

0:00​​ - Introduction
1:17 - pip install flask_login
2:50 - import flask_login to app
3:17 - Add UserMixin to User Model
3:48 - Add Username To Users Model
4:33 - Make DB Migration
5:03 - Add Username Field UserForm
5:32 - Add Username Field Add_User View
6:21 - Add Username Field To Web Form
7:12 - Add Username To Webpage
9:46 - Create Login Route and View
10:36 - Create Dashboard Route and View
11:02 - Create LoginForm
12:10 - Add Login Link To Navbar
13:06 - Add Flask_login Configuration
15:03 - Make Dashboard @Login_required
15:42 - Validate Login Form
17:00 - Check Password Hash
18:51 - Show Flash Messages
19:54 - Test It Out!
20:33 - Create Logout Functionality
21:54 - Add Logout Link To Dashboard
22:26 - Conclusion
Рекомендации по теме
Комментарии
Автор

▶️ Watch Entire Flask Friday Playlist ✅ Subscribe To My YouTube Channel:
▶️ See More At: ✅ Join My Facebook Group:
▶️ Get The Code

Codemycom
Автор

I spent a whole day trying to understand the explanation in the documentation just to end up frustrated and lost among all the content imo poorly explained there. With this video I just understood it all, thanks a lot.

ricardocaballero
Автор

Amazing explanation! I've seen quite a few of your Flask Friday videos already and I plan to watch more as I go on learning. I especially appreciate how at the end of the video you pointed out the parts that you didn't have time to explain more deeply, so I won't stay here wondering why I didn't understand all of it. 🤭Thank you so much for the whole series! 😊👏

hiutale
Автор

Lots of material in a short amount of time. Works beautifully. Thank you.

teclote
Автор

srsly man, you are highly underrated. youtubers who upload this regularly are rare. keep up the great work!

aditya_asundi
Автор

The work you do giving us these pills is amazing. As a "studen" i think its just the best way to go, but when i think how underpaid it is in terms of views (and imagine revenew) of your videos (because i think people start the tutorial series but let it unfinished, or just come to see an specific topic on flask or whatever so it only got residual views), i think you should edit it when you finish your tutorials in a single long video and relaunch it with some fancy name as freecodecamp tutorials or something like that... im pretty positive each of your tutorials would have hundred of thousands views, and attract more suscribers to your channel.

I know your offer those tutorials completed on your site (i already bought access) but well... just wanted to share my view with you.

My best desires bro, i just hope all the help you bring will be fairly rewarded

JaviMstv
Автор

i love and enjoy watching your videos, keep going

gangjiatharva
Автор

Gone through 20 of your friday flask videos in two days already. They are fantastic you are great man! Sometimes I would love some extra info on why we add things and what they do but it's all good I can find out more in the documentation. By the way, the file is getting pretty big, shouldn't we split it into chunks now? :D

dwpk
Автор

Hi John, great content! Really like the hands-on approach. I do have a question though:

How could I build a view e.g. 'profile', which could be seen by all users (like in social media) and another view e.g. 'dashboard' which is private for each user allowing them to edit their profile and see their specific content?

Thanks in advance!

N.el.M
Автор

Never thought that Walter White is gonna teach me

ecgisamal
Автор

Amazing job John, thank you for it. BTW: I do believe that methods=['GET', 'POST'] are not necessary for LOGOUT and DASHBOARD functions. Or did I overlook something?

strycinek
Автор

The beginning was very confusing for a noob like me :D

troyhackney
Автор

thanks for the videos you are doing.my big likes to your videos .good luck

mynameisgod
Автор

Hi!, been watching this playlist for days now. Great stuff! I have a slight problem tho. Whenever I update/upgrade the database, the entries still followed the last id even though I deleted the records like you instructed, before upgrading the database. Any thoughts?

georlybibas
Автор

Hi, any idea how to setup the expiry or duration for he the cookie? Thank you! I think it should have something to do with the login_user method, but I am not able to make it work

waynelei
Автор

once you press the logout button and press the backspace key do you land on the accounts page? and how to resolve this issue?

ironF
Автор

I am beginner to Flask Framework

I need to know that if I have multiple kind of users eg, student and teacher and I'm doing it all in same models.py file so do I have to set 2 LoginManager() instance in the models.py like also teacher_login_manger?

the_noob_
Автор

Sir I hate every time flask app reloads itself when we press submit and login button or just updated or delete Database ( is any solution to Stop reloading .... Every single time ) ..?

idk____idk
Автор

Hi, I am using MySQL to store the data. How can I integrate flask-login with it?

advityadua
Автор

Hey!
New to the channel, very cool video. I have a SignUp and LogIn Feature working in my Flask App. However, Im using HTML Animations that play when the url is loaded. Do you know a way to render the "wrong username or password" messages without realoading the page itself? Ive checked a lot of real-world websites and most of the time once you hit "login" the site does not reaload, it just displays the message.

Any tip is greatly appreciated!

happypants