flask-login

Is there a way to login a user using Flask Socket IO?

独自空忆成欢 提交于 2021-01-29 09:43:57
问题 I'm using Flask with Flask SocketIO and Flask Login . My issue is that when I tried to use the login_user function inside of a socketio.on event, there is no error, but the user isn't logged in. My example might help illustrate this. my example event will be called for the user to login, and then /usersonly will be for after that event is called. @socketio.on('my example event') def my_func(json): ... login_user(user) @app.route('/usersonly') @login.user_required def my_call(): print(current

PyCharm warns about unexpected arguments for SQLAlchemy User model

浪子不回头ぞ 提交于 2021-01-27 06:46:52
问题 I'm working with Flask-SQLAlchemy in PyCharm. When I try to create instances of my User model by passing keyword arguments to the model, PyCharm highlights the arguments with an "Unexpected argument(s)" warning. When I create instances of other models, I don't get this warning. Why am I getting this error for my User model? class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String, unique=True, nullable=False) new_user = User(username="test")

PyCharm warns about unexpected arguments for SQLAlchemy User model

会有一股神秘感。 提交于 2021-01-27 06:43:39
问题 I'm working with Flask-SQLAlchemy in PyCharm. When I try to create instances of my User model by passing keyword arguments to the model, PyCharm highlights the arguments with an "Unexpected argument(s)" warning. When I create instances of other models, I don't get this warning. Why am I getting this error for my User model? class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String, unique=True, nullable=False) new_user = User(username="test")

I am trying to learn Flask, but UserMixin seems not to work

末鹿安然 提交于 2021-01-27 06:31:35
问题 So to be more exact. I am currently learning Flask from Corey Schafers tutorial series and I am in the phase of Login Authentication, everything seemed to be fine, but then I got this error after trying to log in: AttributeError AttributeError: 'User' object has no attribute 'is_active' Traceback (most recent call last) File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 2463, in __call__ return self.wsgi_app(environ, start_response) File "C:\Users\panda

flask-login: Chrome ignoring cookie expiration?

ⅰ亾dé卋堺 提交于 2020-12-27 08:15:38
问题 I've got the authentication working with flask-login, but it seems like no matter what I use for the cookie duration in flask, the session is still authenticated. Am I setting the config variables properly for flask-login? I've tried app.REMEMBER_COOKIE_DURATION = datetime.timedelta(seconds=30) app.config["REMEMBER_COOKIE_DURATION"] = datetime.timedelta(seconds=30) Even if I close the browser, wait a while, and hit a url that should be protected, I can still access it. Is this related to this

flask-login: Chrome ignoring cookie expiration?

百般思念 提交于 2020-12-27 08:14:24
问题 I've got the authentication working with flask-login, but it seems like no matter what I use for the cookie duration in flask, the session is still authenticated. Am I setting the config variables properly for flask-login? I've tried app.REMEMBER_COOKIE_DURATION = datetime.timedelta(seconds=30) app.config["REMEMBER_COOKIE_DURATION"] = datetime.timedelta(seconds=30) Even if I close the browser, wait a while, and hit a url that should be protected, I can still access it. Is this related to this

flask-login: Chrome ignoring cookie expiration?

余生颓废 提交于 2020-12-27 08:13:04
问题 I've got the authentication working with flask-login, but it seems like no matter what I use for the cookie duration in flask, the session is still authenticated. Am I setting the config variables properly for flask-login? I've tried app.REMEMBER_COOKIE_DURATION = datetime.timedelta(seconds=30) app.config["REMEMBER_COOKIE_DURATION"] = datetime.timedelta(seconds=30) Even if I close the browser, wait a while, and hit a url that should be protected, I can still access it. Is this related to this