-
Notifications
You must be signed in to change notification settings - Fork 0
Description
에러 코드 :
ValueError at /accounts/recovery/pw/reset/
You have multiple authentication backends configured and therefore must provide the backend argument or set the backend attribute on the user.
try1) 백엔드 지정
django의 EmailBackend 지정
backend='django.contrib.auth.backends.ModelBackend'
django의 EmailBackend는 사용자 인증까지는 제공하지 않음
try2) 자체 backend 생성
backend.py 파일 생성 ,
...
class EmailBackend(ModelBackend):
def authenticate(self, request, email=None, password=None, **kwargs):
...
EmailBackend 생성, views에 적용
current_user = authenticate(request, username=session_user, backend='accounts_app.backends.EmailBackend')
해결 안 됨..
try3) django-allauth이용
django-allauth에서 제공하는 비밀번호 찾기 서비스 이용 시도
uPC_project.urls.py => path('accounts/', include('allauth.urls')), 추가, settings.py 수정
제작한 html에 대해 오버라이드가 원래 되어야 하지만 안 됨..
solution :
로직 변경
기존 로직) 유저 로그인 -> 비밀번호 변경 저장 -> 로그아웃
변경 로직) django에서 제공하는 set_password() 이용
user = reset_password_form.save()
-> current_user.set_password(request.POST['new_password1'])
current_user.save()