私のアプリケーションは、Webサイト(同じページ)にログインする2つの方法を提供します。最初はユーザー名&パスワードであり、その他はユーザー名&緊急パスワードです。私はbackend.pyとして複数の値を返すdjango
class PersonAuthenticationBackend(object):
def authenticate(self, username=None, password=None):
try:
person = User.objects.get(username=username)
if person.check_password(password):
return person
else:
try:
db_ecode=person.get_profile().u_emergency_code
if password==db_ecode:
print "EMERGENCY LOGIN"
return person
else :
return None
except:
return None
except User.DoesNotExist:
pass
return None
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None
を持っています。ユーザーが緊急ログインを使用してログインしているかどうかを知るにはどうすればいいですか?
"EMERGENCY LOGIN"の行が出力されていることを確認してください。 :-)どのような作業を解決しようとしていますか? – DrTyrsa
質問にはコード内でそれを知る必要がありますか?あなたはすでに "緊急のログイン"の文字列を印刷するときにそれを知っています。 – akonsu