python - Flask-login shows unicode type not callable -


i tried using flask-login handle login , session.

on registration process, once details validated, can use login_user(user) , redirect homepage.

i have problem doing login process. upon trying login, there error raised in login_user(user)

'unicode' object not callable' 

on flask-login documentation says get_id() must return unicode, have done.i.e:

def get_id(self):     return text_type(self.id) 

i have imported text_type (from 6 import text_type). wrote return self.id. says :

long object not callable 

how solve ?

below login method:

@app.route('/login', methods=['get','post']) def login(): if request.method == 'post':     email = request.form['email']     password = request.form['password']     if email , password:         error = "invalid email/password!"         user = session.query(user).filter_by(email=email).first()         if user:             hpass = hash_str(password)             if user.password == hpass:                 login_user(user, remember=true)                 return redirect('/')             else:                 return render_template('login.html', alert=render_template('alert.html', errormsg=error))         else:             return render_template('login.html', alert=render_template('alert.html', errormsg=error))  else:     return render_template('login.html') 

it raises error on line login_user(user) thanks.

solved it!

so error due using keyword 'id' inside load_user

changed to:

def load_user(userid):     user_id = int(userid)     return user.query.get(user_id) 

on user class:

def get_id(self):     return unicode(self.id) 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -