def clean(self): priv, pub = get_keys() if not compare_string(self.cleaned_data.get("public_key"), pub.decode()): raise forms.ValidationError("公钥失效,请刷新重试。") try: self.cleaned_data["password"] = decryptRSA(self.cleaned_data["password"], priv).decode() except: raise forms.ValidationError("解码失败,请刷新重试。") return super().clean()
def clean(self): priv, pub = get_keys() if not compare_string(self.cleaned_data.get("public_key"), pub.decode()): raise forms.ValidationError( "Public key expired. Refresh the page to continue.") try: self.cleaned_data["password"] = decryptRSA( self.cleaned_data["password"], priv).decode() except: raise forms.ValidationError( "Password decoding failed. Refresh the page to retry.") return super().clean()
def clean(self): data = super(RegisterForm, self).clean() priv, pub = get_keys() if not compare_string(data.get("public_key"), pub.decode()): raise forms.ValidationError("公钥失效,请刷新重试。") try: data["password"] = decryptRSA(data["password"], priv).decode() data["repeat_password"] = decryptRSA(data["repeat_password"], priv).decode() except: raise forms.ValidationError("解码失败,请刷新重试。") if data.get('password') != data.get('repeat_password'): self.add_error('repeat_password', forms.ValidationError("密码不匹配。", code='invalid')) return data
def clean(self): data = super(RegisterForm, self).clean() priv, pub = get_keys() if not compare_string(data.get("public_key"), pub.decode()): raise forms.ValidationError( "Public key expired. Refresh the page to continue.") try: data["password"] = decryptRSA(data["password"], priv).decode() data["repeat_password"] = decryptRSA(data["repeat_password"], priv).decode() except: raise forms.ValidationError( "Password decoding failed. Refresh the page to retry.") if data.get('password') != data.get('repeat_password'): self.add_error( 'repeat_password', forms.ValidationError(_("Password doesn't match."), code='invalid')) return data