def login(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] try: Auth.login(username, password) session['username'] = username return redirect(url_for('menu.getstart')) except ErrorHandlers.ErrorHandler as e: flash(e.message, 'error') return render_template('/login.html')
def get_auth_token(): #content type should be application/json data = request.get_json() username = data['username'] password = data['password'] authObj = Auth() login_response = authObj.login(username,password) if not login_response : return jsonify({'message' : 'Invalid username or password'}) token = authObj.encode_auth_token(login_response['user_id'],login_response['is_admin']) return jsonify({ 'token' : token})