flask-login

Flask Login: TypeError: decoding Unicode is not supported

佐手、 提交于 2019-12-21 04:06:28
问题 I am running flask, pymongo and flask-login as a stack. My flask app is running fine locally, but once I deploy it with uwsgi on nginx, I get a strange unicode error from flask_login extension. In short: TypeError: decoding Unicode is not supported Traceback: [pid: 21753|app: 0|req: 5/5] 84.207.253.34 () {38 vars in 600 bytes} [Thu Jun 13 16:51:08 2013] GET / => generated 0 bytes in 4 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0) Traceback (most recent call last): File "

@login_required trouble in flask app

ε祈祈猫儿з 提交于 2019-12-19 16:35:20
问题 I have created a blueprint that handles authenticating. This blue print uses Flask-Login. And has the following, as well as more code not shown. In the blueprint I have the following: from flask.ext.login import LoginManager from flask.ext.login import UserMixin from flask.ext.login import current_user from flask.ext.login import login_required from flask.ext.login import login_user from flask.ext.login import logout_user auth_print = Blueprint('auth_print', __name__) login_manager =

@login_required trouble in flask app

匆匆过客 提交于 2019-12-19 16:33:14
问题 I have created a blueprint that handles authenticating. This blue print uses Flask-Login. And has the following, as well as more code not shown. In the blueprint I have the following: from flask.ext.login import LoginManager from flask.ext.login import UserMixin from flask.ext.login import current_user from flask.ext.login import login_required from flask.ext.login import login_user from flask.ext.login import logout_user auth_print = Blueprint('auth_print', __name__) login_manager =

How to track the current user in flask-login?

心已入冬 提交于 2019-12-18 12:15:02
问题 I m trying to use the current user in my view from flask-login. So i tried to g object I m assigning flask.ext.login.current_user to g object @pot.before_request def load_users(): g.user = current_user.username It works if the user is correct. But when i do sign-up or login as with wrong credentials I get this error AttributeError: 'AnonymousUserMixin' object has no attribute 'username' Please enlight me where am i wrong... 回答1: Thanks for your answer @Joe and @pjnola, as you all suggested i

BuildError: Could not build url for endpoint 'user' with values ['nickname']. Did you forget to specify values ['page', 'username']?

与世无争的帅哥 提交于 2019-12-14 03:58:11
问题 I am getting the following error when I try to goto index.html on my site. The site was templated from https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-v-user-logins I modified it to take in usernames/passwords and got rid of openid. I went through and replaced nickname in the database with username and somehow it is still referencing it even after I have updated the database. I'm still new to this so please go easy. I searched for how to build url's and can't find anything I

Flask - How to store logs and add additional information

喜夏-厌秋 提交于 2019-12-12 03:33:56
问题 I would like to store "werkzeug" output in a file (or create a similar log file) and add additional data to each line of log. (For example a value for the username if the value is known in the session) How to proceed ? I would like the user to be "unknown" if the username is not known in the session. Is it possible to define everything before doing app.run() ? (Because I did ran into 'working outside of request context' errors when trying to use the session object before app.run) class

Why is my decorator breaking for this Flask-Login endpoint?

若如初见. 提交于 2019-12-11 13:03:26
问题 I've figured out how to make Flask-Login authenticate a user based on an LDAP lookup. Now I'd like to add some authorization to the mix - that is, only allow access to certain endpoints if a user has both logged in and belongs to the right groups. I'm not sure if this is the right way to do it, but I thought I could just add a decoration to an endpoint: @app.route('/top_secret') @authorize @login_required def top_secret(): return render_template("top_secret.html") and (for now) make a

Redirect to previous URL after OAuth login is completed (flask-dance)

只谈情不闲聊 提交于 2019-12-11 06:34:48
问题 I am developing a Flask application that allows the user to login using OAuth (with Github as a provider), and the flask-dance library. For some reason I am not able to redirect, after a successful login, to the page from which I sent the user to the login page. When the user tries to connect to, e.g., http://localhost:6675/examples/tutorial.first/, the user is redirected to the login page, showing in the URL the page we should redirect to (http://localhost:6675/login?next=%2Fexamples

Redirect to login page rather than showing a Forbidden message when not logged in

可紊 提交于 2019-12-11 03:14:16
问题 I have a authenticated_resource decorator that prevents access to some routes if the user is not logged in. I'd like to redirect to the login page if the user is not logged in, but right now it shows a "Forbidden" message instead. How do I redirect? Forbidden You don't have the permission to access the requested resource. It is either read-protected or not readable by the server. @app.route('/metering') @authenticated_resource def getstats(): token = session.get('auth_token') print 'token in

Flask login @login_required not working

好久不见. 提交于 2019-12-11 01:02:57
问题 I'm using flask-login to make sure users are logged in before they can access certain pages. I'm using @login_required on the view I want to protect, but even though I'm setting login_user(user) where I'm wanting to set the user, it does not let me go into my protected route (index). I'm printing out the value of my user_login(user) and it returns True . What am I doing wrong? @app.route('/') @app.route('/index') @login_required def index(): print("was in here", file=sys.stderr) return render