def save(self, commit=True): user = super(SRPUserCreationForm, self).save(commit=False) user.password = UNUSABLE_PASSWORD srpinfo = SRPUserInfo() srpinfo.verifier = self.cleaned_data['verifier'] srpinfo.salt = self.cleaned_data['salt'] srpinfo.srp_group = self.cleaned_data['srp_group'] if commit: user.save() srpinfo.user = user srpinfo.save() return user
def save(self, commit=True): user = super(SRPUserCreationForm, self).save(commit=False) user.password = UNUSABLE_PASSWORD srpinfo = SRPUserInfo() srpinfo.verifier = self.cleaned_data["verifier"] srpinfo.salt = self.cleaned_data["salt"] srpinfo.srp_group = self.cleaned_data["srp_group"] if commit: user.save() srpinfo.user = user srpinfo.save() return user
def handle(self, *args, **options): if len(args) != 2: raise CommandError("must specify username and password") username = args[0] password = args[1] try: user = User.objects.get(username=username) except User.DoesNotExist: user = User(username=username, password=UNUSABLE_PASSWORD) user.save() try: srpinfo = SRPUserInfo.objects.get(user=user) except SRPUserInfo.DoesNotExist: srpinfo = SRPUserInfo(user=user) srpinfo.set_from_password(password) srpinfo.save()