diff --git a/happydomain/admin.py b/happydomain/admin.py index c9c1086..075cadb 100644 --- a/happydomain/admin.py +++ b/happydomain/admin.py @@ -65,20 +65,6 @@ class Admin: return ret - def authuser_reset_password(self, Id, NewPassword): - r = self.session.post( - "http+unix://" + self.socket_path + "/api/auth/" + quote_plus(Id) + "/reset_password", - data=json.dumps({ - "password": NewPassword, - }) - ) - - if r.status_code != 200: - raise HappyError(r.status_code, **r.json()) - - from .authuser import AuthUser - return r.json() - def authuser_udpate(self, Id, au): r = self.session.put( "http+unix://" + self.socket_path + "/api/auth/" + quote_plus(Id), diff --git a/happydomain/authuser.py b/happydomain/authuser.py index b9c4c9d..c9d72e9 100644 --- a/happydomain/authuser.py +++ b/happydomain/authuser.py @@ -14,8 +14,18 @@ class AuthUser: def Delete(self): self._session.authuser_delete(self.Id) - def ResetPassword(self, *args, **kwargs): - self._session.authuser_reset_password(self.Id, *args, **kwargs) + def ResetPassword(self, Id, NewPassword): + r = self.session.post( + "http+unix://" + self.socket_path + "/api/auth/" + quote_plus(Id) + "/reset_password", + data=json.dumps({ + "password": NewPassword, + }) + ) + + if r.status_code != 200 and r.status_code != 406: + raise HappyError(r.status_code, **r.json()) + + return r.status_code == 200 def Update(self): self._session.authuser_update(self.Id, self)