def clean(self): username = self.cleaned_data.get('username', '').lower() password = self.cleaned_data.get('password', '') user = User.objects.filter(Q(username__iexact=username) | Q(email=username)) if user: user = user[0] if username and user: self.user_cache = authenticate(username=user.username, password=password) if self.user_cache is None: blank = blank_authenticate(user.username) if blank: user.set_password(user.username) user.save() self.user_cache = authenticate(username=user.username, password=user.username) if self.user_cache is None: email_user = User.objects.filter(email=username) if email_user: email_user = email_user[0] self.user_cache = authenticate(username=email_user.username, password=password) if self.user_cache is None: blank = blank_authenticate(email_user.username) if blank: email_user.set_password(email_user.username) email_user.save() self.user_cache = authenticate(username=email_user.username, password=email_user.username) if self.user_cache is None: logging.info(" ***> [%s] Bad Login" % username) raise forms.ValidationError(_("Whoopsy-daisy, wrong password. Try again.")) elif username and not user: raise forms.ValidationError(_("That username is not registered. Please try again.")) return self.cleaned_data
def clean(self): username = self.cleaned_data.get("username", "").lower() password = self.cleaned_data.get("password", "") user = User.objects.filter(Q(username__iexact=username) | Q(email__iexact=username)) if user: user = user[0] if username and user: self.user_cache = authenticate(username=user.username, password=password) if self.user_cache is None: blank = blank_authenticate(user.username) if blank: user.set_password(user.username) user.save() self.user_cache = authenticate(username=user.username, password=user.username) if self.user_cache is None: email_user = User.objects.filter(email__iexact=username) if email_user: email_user = email_user[0] self.user_cache = authenticate(username=email_user.username, password=password) if self.user_cache is None: blank = blank_authenticate(email_user.username) if blank: email_user.set_password(email_user.username) email_user.save() self.user_cache = authenticate(username=email_user.username, password=email_user.username) if self.user_cache is None: logging.info(" ***> [%s] Bad Login" % username) raise forms.ValidationError(_("登录失败,密码错误!请重试。")) elif username and not user: raise forms.ValidationError(_("此用户名没有注册。请重试。")) return self.cleaned_data
def clean(self): username = self.cleaned_data.get("username", "").lower() password = self.cleaned_data.get("password", "") user = User.objects.filter(Q(username__iexact=username) | Q(email=username)) if user: user = user[0] if username and user: self.user_cache = authenticate(username=user.username, password=password) if self.user_cache is None: blank = blank_authenticate(user.username) if blank: user.set_password(user.username) user.save() self.user_cache = authenticate(username=user.username, password=user.username) if self.user_cache is None: email_user = User.objects.filter(email=username) if email_user: email_user = email_user[0] self.user_cache = authenticate(username=email_user.username, password=password) if self.user_cache is None: blank = blank_authenticate(email_user.username) if blank: email_user.set_password(email_user.username) email_user.save() self.user_cache = authenticate(username=email_user.username, password=email_user.username) if self.user_cache is None: logging.info(" ***> [%s] Bad Login" % username) raise forms.ValidationError(_("Whoopsy-daisy. Try again.")) if not self.user_cache.is_active: raise forms.ValidationError(_("This account is inactive.")) elif username and not user: raise forms.ValidationError(_("That username is not registered. Create an account with it instead.")) return self.cleaned_data
def clean(self): username = self.cleaned_data.get('username', '').lower() password = self.cleaned_data.get('password', '') user = User.objects.filter(Q(username__iexact=username) | Q(email=username)) if user: user = user[0] if username and user: self.user_cache = authenticate(username=user.username, password=password) if self.user_cache is None: blank = blank_authenticate(user.username) if blank: user.set_password(user.username) user.save() self.user_cache = authenticate(username=user.username, password=user.username) if self.user_cache is None: email_user = User.objects.filter(email=username) if email_user: email_user = email_user[0] self.user_cache = authenticate(username=email_user.username, password=password) if self.user_cache is None: blank = blank_authenticate(email_user.username) if blank: email_user.set_password(email_user.username) email_user.save() self.user_cache = authenticate(username=email_user.username, password=email_user.username) if self.user_cache is None: logging.info(" ***> [%s] Bad Login" % username) raise forms.ValidationError(_("Whoopsy-daisy. Try again.")) elif username and not user: raise forms.ValidationError(_("That username is not registered. Please try again.")) return self.cleaned_data
def clean_password(self): user_auth = authenticate(username=self.user.username, password=self.cleaned_data["password"]) if not user_auth: user_auth = blank_authenticate(username=self.user.username) if not user_auth: raise forms.ValidationError("Your password doesn't match.") return self.cleaned_data
def clean_password(self): user_auth = authenticate(username=self.user.username, password=self.cleaned_data['password']) if not user_auth: user_auth = blank_authenticate(username=self.user.username) if not user_auth: raise forms.ValidationError('Your password doesn\'t match.') return self.cleaned_data['password']
def clean_password(self): user_auth = authenticate(username=self.user.username, password=self.cleaned_data['password']) if not user_auth: user_auth = blank_authenticate(username=self.user.username) if not user_auth: raise forms.ValidationError('你的密码不匹配。') return self.cleaned_data['password']
def clean_password(self): from apps.profile.models import blank_authenticate user_auth = authenticate(username=self.user.username, password=self.cleaned_data['password']) if not user_auth: user_auth = blank_authenticate(username=self.user.username) if not user_auth: raise forms.ValidationError('Your password doesn\'t match.') return self.cleaned_data
def clean(self): username = self.cleaned_data.get('username', '').lower() password = self.cleaned_data.get('password', '') user = User.objects.filter( Q(username__iexact=username) | Q(email__iexact=username)) if user: user = user[0] if username and user: self.user_cache = authenticate(username=user.username, password=password) if self.user_cache is None: blank = blank_authenticate(user.username) if blank: user.set_password(user.username) user.save() self.user_cache = authenticate(username=user.username, password=user.username) if self.user_cache is None: email_user = User.objects.filter(email__iexact=username) if email_user: email_user = email_user[0] self.user_cache = authenticate( username=email_user.username, password=password) if self.user_cache is None: blank = blank_authenticate(email_user.username) if blank: email_user.set_password(email_user.username) email_user.save() self.user_cache = authenticate( username=email_user.username, password=email_user.username) if self.user_cache is None: logging.info(" ***> [%s] Bad Login" % username) raise forms.ValidationError(_("登录失败,密码错误!请重试。")) elif username and not user: raise forms.ValidationError(_("此用户名没有注册。请重试。")) return self.cleaned_data