mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-02 07:00:51 -04:00
replace user PUT with POSTs
the update_user fn was used in two places, for things that are handled fine by update_user_attribute. Reduce complexity in the API by killing the PUT, which is more dangerous (might silently overwrite things that shouldn't be, like "last_logged_in_at" etc). Had to change the code not received mobile number form, and the activate user function.
This commit is contained in:
@@ -54,12 +54,6 @@ class UserApiClient(NotifyAdminAPIClient):
|
||||
users.append(User(user, max_failed_login_count=self.max_failed_login_count))
|
||||
return users
|
||||
|
||||
def update_user(self, user):
|
||||
data = user.serialize()
|
||||
url = "/user/{}".format(user.id)
|
||||
user_data = self.put(url, data=data)
|
||||
return User(user_data['data'], max_failed_login_count=self.max_failed_login_count)
|
||||
|
||||
def update_user_attribute(self, user_id, **kwargs):
|
||||
data = dict(kwargs)
|
||||
disallowed_attributes = set(data.keys()) - ALLOWED_ATTRIBUTES
|
||||
@@ -155,7 +149,9 @@ class UserApiClient(NotifyAdminAPIClient):
|
||||
def activate_user(self, user):
|
||||
if user.state == 'pending':
|
||||
user.state = 'active'
|
||||
return self.update_user(user)
|
||||
url = "/user/{}".format(user.id)
|
||||
user_data = self.post(url, data={'state': 'active'})
|
||||
return User(user_data['data'], max_failed_login_count=self.max_failed_login_count)
|
||||
else:
|
||||
return user
|
||||
|
||||
|
||||
Reference in New Issue
Block a user