Island: Change PATCH to PUT in propagation_credentials resource

* Add support to put stolen credentials
This commit is contained in:
Ilija Lazoroski 2022-07-21 14:48:20 +02:00
parent 45884ff233
commit 89299bac6d
3 changed files with 15 additions and 9 deletions

View File

@ -42,13 +42,20 @@ class PropagationCredentials(AbstractResource):
return {}, HTTPStatus.NO_CONTENT
def patch(self, collection=None):
if collection != _configured_collection:
return {}, HTTPStatus.METHOD_NOT_ALLOWED
def put(self, collection=None):
credentials = [Credentials.from_mapping(c) for c in request.json]
self._credentials_repository.remove_configured_credentials()
self._credentials_repository.save_configured_credentials(credentials)
if collection == _configured_collection:
self._credentials_repository.remove_configured_credentials()
self._credentials_repository.save_configured_credentials(credentials)
elif collection == _stolen_collection:
self._credentials_repository.remove_stolen_credentials()
self._credentials_repository.save_stolen_credentials(credentials)
elif collection is None:
return {}, HTTPStatus.METHOD_NOT_ALLOWED
else:
return {}, HTTPStatus.NOT_FOUND
return {}, HTTPStatus.NO_CONTENT
def delete(self, collection=None):

View File

@ -42,7 +42,6 @@ const ConfigImportModal = (props: Props) => {
useEffect(() => {
if (configContents !== null && configCredentials !== null) {
console.log("useEffect was called");
tryImport();
}
}, [configContents, configCredentials, unsafeOptionsVerified])
@ -80,7 +79,7 @@ const ConfigImportModal = (props: Props) => {
console.log(credentials);
authComponent.authFetch(credentialsEndpoint,
{
method: 'PATCH',
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(credentials)
}

View File

@ -300,7 +300,7 @@ class ConfigurePageComponent extends AuthComponent {
return (
this.authFetch(CONFIGURED_PROPAGATION_CREDENTIALS_URL,
{
method: 'PATCH',
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(formatCredentialsForIsland(this.state.credentials))
})