def user_loader(mobile): if mobile is None: return element = dao.getUserByMobile(mobile) if element is None : return dbUser = user(element['nickName'],element['masterPassword'],element['mobile'],element['email'],element['status'],element['createTime']) dbUser.id = mobile return dbUser
def login(): mobile =request.form['mobile'] element = dao.getUserByMobile(mobile) if element is None or encrypt(request.form['masterPassword']) != element['masterPassword'] : return 'Bad login' current_user = user(element['nickName'], element['masterPassword'], element['mobile'], element['email'], element['status'], element['createTime']) current_user.id=mobile flask_login.login_user(current_user) return redirect('/')