0
로그인 성공시 페이지를 리디렉션하려고하지만 동일한 문제가 계속 발생합니다.플라스크에 URL 리디렉션 - 로그인
내 로그인 코드 :
@app.route('/login/', methods = ['GET', 'POST'])
def login():
if request.method == 'POST':
#data = request.get_json()
#app.logger.debug(data)
auth = g.couch.get('_design/authentication')
authView = ViewDefinition('_design/authentication','authentication',auth['views']['authentication']['map'])
for row in authView():
if request.form['username'] == row.value['username'] and request.form['password'] == row.value['password']:
authUser = userModel.User(row.value)
app.logger.debug(row.value)
authUser.authenticated = True;
flask_login.login_user(authUser,remember = True)
next = request.args.get('next')
return redirect(next or url_for('/protected/'))
return render_template('sampleLoginPage.html')
@app.route('/protected/', methods = ['GET'])
@flask_login.login_required
def protected():
app.logger.debug("Successful Login")
app.logger.debug(flask_login.current_user.userID)
return Response(json.dumps({'message' : '\'You\'re logged in so you can see this page'+flask_login.current_user.username}), mimetype = 'application/json')
HTML 템플릿은 사용자 이름과 암호를 선택합니다. 사용자를 인증하는 couchdb보기가 있습니다. 난 내 로그인 자격 증명을 입력하면 나는 완전히 설명서를 이해하지 못했다
http://192.168.1.109:5000/login/?next=%2Fprotected%2F
에
는 URL을 리디렉션합니다. 누군가이 개념을 더 잘 설명 할 수 있을까요? 나는 왜 이것을 얻고 있는가?
내 angularjs 프런트 엔드에 연결할 때도 발생합니다.
감사합니다, 선일
'flask_login''user_loader' 함수를 표시 할 수 있습니까? – Wombatz
안녕하세요 웜뱃입니다. 늦어서 죄송합니다. 프런트 엔드에 문제가있는 것으로 보입니다 (저는 AngularJS를 사용하고 있습니다). 우편함이나 브라우저를 사용할 때 로그인이 완벽하게 작동합니다. 앱 에뮬레이터를 통해 액세스 할 때만이 오류가 발생합니다. – galeej