From 6a6bcd00842265e315e648cbaa7e6142cc43d573 Mon Sep 17 00:00:00 2001 From: Nathan Mkaya Date: Thu, 7 Nov 2019 13:04:44 +0300 Subject: [PATCH] Fix Issue #69 (#71) Added check if token is empty raise an error --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bf2345c..bbe032d 100644 --- a/Makefile +++ b/Makefile @@ -145,7 +145,10 @@ deploy: dist ## or copying the files directly to a sibling mattermost-server directory. ifneq ($(and $(MM_SERVICESETTINGS_SITEURL),$(MM_ADMIN_USERNAME),$(MM_ADMIN_PASSWORD),$(CURL)),) @echo "Installing plugin via API" - $(eval TOKEN := $(shell curl -i --post301 --location $(MM_SERVICESETTINGS_SITEURL) -X POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/users/login -d '{"login_id": "$(MM_ADMIN_USERNAME)", "password": "$(MM_ADMIN_PASSWORD)"}' | grep Token | cut -f2 -d' ' 2> /dev/null)) + $(eval TOKEN := $(shell curl -i --fail --post301 --location $(MM_SERVICESETTINGS_SITEURL) -X POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/users/login -d '{"login_id": "$(MM_ADMIN_USERNAME)", "password": "$(MM_ADMIN_PASSWORD)"}' | grep Token | cut -f2 -d' ' 2> /dev/null)) + @if [$(TOKEN) == '']; then\ + $(error Failed to authenticate and extract token using $(MM_ADMIN_USERNAME): check server logs.)\ + fi @curl -s --post301 --location $(MM_SERVICESETTINGS_SITEURL) -H "Authorization: Bearer $(TOKEN)" -X POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/plugins -F "plugin=@dist/$(BUNDLE_NAME)" -F "force=true" > /dev/null && \ curl -s --post301 --location $(MM_SERVICESETTINGS_SITEURL) -H "Authorization: Bearer $(TOKEN)" -X POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/plugins/$(PLUGIN_ID)/enable > /dev/null && \ echo "OK." || echo "Sorry, something went wrong."