flask, flask-sqlalchemy & flask-login で個人アプリのログイン・会員登録機能を作っています。会員登録機能は問題なく動作しているんですが、ログインができません。
登録されているメールアドレスとパスワードでログインを試みると、 Please log in to access this page. と怒られます。
python
1def login_post(): 2 email = request.form.get('email') 3 password = request.form.get('password') 4 remember = True if request.form.get('remember') else False 5 6 user = User.query.filter_by(email=email).first() 7 8 if not user or not check_password_hash(user.password, password): 9 flash('Please check your login details and try again.') 10 return redirect(url_for('auth.login')) 11 12 login_user(user, remember=remember) 13 14 return redirect(url_for('main.profile'))
python
1@main.route('/profile', methods=['GET']) 2@login_required 3def profile() -> Text: 4 return render_template('profile.html', name=current_user.name)
おそらく @login_required で引っかかっているんだと思います。
登録済みのアカウントでログインができる状態にしたいです。
参考にしている記事はこちらです => https://scotch.io/tutorials/authentication-and-authorization-with-flask-login
関係ないかもしれませんが、ログインフォームに文字を入力し、実行した後の URL は http://127.0.0.1:5000/login?next=%2Fprofile でした。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。