diff options
Diffstat (limited to 'account.py')
-rw-r--r-- | account.py | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -96,7 +96,7 @@ class AccountService: def get_by_uid(self, uid): """ Find a single user by uid. Unlike find_by_uid, don't return a list but - raise ValueError if there is no such user. + raise NoSuchUserError if there is no such user. """ users = self.find_by_uid(uid) if len(users) != 1: @@ -104,6 +104,17 @@ class AccountService: return users[0] + def get_by_mail(self, mail): + """ + Find a single user by mail. Unlike find_by_mail, don't return a list but + raise NoSuchUserError if there is no such user. + """ + users = self.find_by_mail(mail) + if len(users) != 1: + raise NoSuchUserError('No such user') + + return users[0] + def find_by_uid(self, uid, wildcard=False): return self.find({'uid': uid}, wildcard) |