sorry to be so offtopic but does anybody know of a method to get back into an instagram account..? I was stupid forgot the login password. I would love any assistance you can offer me.
@Oakley Shiloh I really appreciate your reply. I found the site through google and im trying it out now. I see it takes a while so I will get back to you later when my account password hopefully is recovered.
I really like your tutorials. I have worked with sql databases for over 20 years and normally don't use sqlalchemy. It is a good program but it is easier for me to use sql. I know you can execute sql from sqlalchemy, but why bother if you don't use the rest of the features? I usually start by creating a class for each table and use sql to do crud operations. Most tutorials for flask-login are 80% sqlalchemy and building an entire authorization system. I already have that. All I needed was the login/logout & session information. Yours is the only tutorial I saw that did not spend most of the time building an entire auth system. As always, your video was short, to the point, and easy to follow.
Awesome :) I've noticed that django does a lot of things automatically vs flask... Flask is the perfect starting point as you will understand more of the hidden django operations :) well explained video 👍
Flask-Login stores the user ID in a cookie. When it reads that cookie, it takes the user ID and calls the query in the user_loader to find the user associated with that cookie.
Thanks for an amazing video. Do you think Flask Login (alongside with Flask-security) can be used with Flask Blueprints? What I'm concerned about is is there a way how to define the User and the db outside of the app.py file, so that everything is a bit more neatly organized?
Thans for the answer. However, I constantly run into ImportErrors when using Flask-security in combination with Blueprints, so I decided to go a different way. Thanks anyway!
I'm thinking of ways to make the playlists more organized here. There are limits to RU-vid playlists, so I may have to put together something on my website.
How is user_id in the load_user function not equal to none?? Because when i put the int() before the user_id it gives me a ValueError invalid literal for int() with base 10: 'None''
In the video, and I am not sure if you will address this in further videos yet, when you are calling a list of users for the usernames what do you do in that case? Is there a video that covers pulling names from this list rather than just the one name? Or do you have to list each of the usernames?
Hi, great video. One question, does Flask-Login make the session secure? Or what to add to make the session secure? If i use a form, is it then to apply Csrf protection to the form?
im stuck at 6:37. my application is call finalProject and i run from finalProject import db but got the error: ImportError: No module named flask_login any help would be appreciated
In your tutorials you put a lot of code in the flask views file. In a more production ready app would most of the computation be done by functions saved in a separate module?
Yeah, it's easier to have all the code in one file for my RU-vid videos. For production apps, you'd be better off separating them if you have a lot of code. I have a video on one way to do it here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-_5OXmXvkU_E.html There are plenty of other ways to do it though.
Great tutorial, My only question is there a cleaner way to apply 'login_required' on multiple methods or i have to decorate every method that requires user login??
When I try to display user username I get info that I'm anonymous user that has no attribute as username. Also I get warning "Unauthorized" when I try to enter a page after logging in
the official documentation argues we MUST include the 'next' algo, see the following, after successful login next = flask.request.args.get('next') if not is_safe_url(next): return flask.abort(400) could you please explain why is it necessary? Thanks. here is the reference: flask-login.readthedocs.io/en/latest/#flask_login.LoginManager.user_loader
The UserMixin makes it easy for Flask Login to know what represents a user. If you don't have that then you'll need to create your own methods so you can use login_user.
Thank you so much for responding. Yes. I have my code in an __init__.py file. ideone.com/JcZFrQ And here is my requirements.txt file, which I have installed PIP packages using virtualenv from. pastebin.com/rPpprzHk The error occurs at the line "return User.query.get(int(user_id))"
I have an external database that I am connected through pypyodcs, would I need to still need to make a user class in the same way you have, as all I want to do is check if the user is logged in, if they are get them to enter there credentials and check against the mssql database.
Yeah, you'll need a user class and a user loader. This is so Flask-Login can map sessions to actual users in your database. It doesn't have to be like a SQLAlchemy class though, where it has all the table information.
ah ok think I got you. So you mean within my user class, I can use a try-except to connect to my mssql db using pypyodbc connector, then from there I can use those credentials to check if the user is logged in or not, am I on the right track? Also is there a way to obtain the user details if logged in, as I need to pass the user details in a post request to an api. Thanks for the help
You don't necessarily need to connect to your database using the user class directly. The user class should just represent a user. The user loader should be a little more direct to your database though, so you can query the database for a particular user given an ID.
Ok can I use the email address as an id? As I don't have any other id in the user table, well there is but it is a crazy long hexnumber I think! I didn't create the table! I'm still a noob, the head developer at my work did