mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-18 21:44:11 -04:00
Admin uses correct endpoint for getting user by email address.
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
from notifications_python_client.notifications import BaseAPIClient
|
||||
from notifications_python_client.errors import (
|
||||
HTTPError,
|
||||
InvalidResponse
|
||||
)
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from flask.ext.login import UserMixin
|
||||
|
||||
@@ -34,6 +31,11 @@ class UserApiClient(BaseAPIClient):
|
||||
user_data = self.get(url)
|
||||
return User(user_data['data'], max_failed_login_count=self.max_failed_login_count)
|
||||
|
||||
def get_user_by_email(self, email_address):
|
||||
params = {'email': email_address}
|
||||
user_data = self.get('/user/email', params=params)
|
||||
return User(user_data['data'], max_failed_login_count=self.max_failed_login_count)
|
||||
|
||||
def get_users(self):
|
||||
users_data = self.get("/user")['data']
|
||||
users = []
|
||||
@@ -57,13 +59,6 @@ class UserApiClient(BaseAPIClient):
|
||||
if e.status_code == 400 or e.status_code == 404:
|
||||
return False
|
||||
|
||||
def get_user_by_email(self, email_address):
|
||||
users = self.get_users()
|
||||
user = [u for u in users if u.email_address == email_address]
|
||||
if len(user) == 1:
|
||||
return user[0]
|
||||
return None
|
||||
|
||||
def send_verify_code(self, user_id, code_type, to):
|
||||
data = {'to': to}
|
||||
endpoint = '/user/{0}/{1}-code'.format(user_id, code_type)
|
||||
|
||||
Reference in New Issue
Block a user