From 3d6f15dd4f931e1cce7d9bb3febbbb43f87ef93b Mon Sep 17 00:00:00 2001 From: Almira Krdzic Date: Mon, 22 Oct 2018 10:35:25 +0200 Subject: [PATCH] return error status on login --- .../includes/class-wiaas-authentication.php | 16 ++++++++++++---- frontend/src/helpers/HtmlClient.js | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-authentication.php b/backend/app/plugins/wiaas/includes/class-wiaas-authentication.php index c49c0f1..5bb41e3 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-authentication.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-authentication.php @@ -73,7 +73,9 @@ class Wiaas_Authentication { // not available roles for user $current_user->set_role(''); - return new WP_Error('wiaas_authentication_error', 'No set permissions!'); + return new WP_Error('wiaas_authentication_error', 'No set permissions!', array( + 'status' => 403, + )); } // authenticate valid admin panel user @@ -115,7 +117,9 @@ class Wiaas_Authentication { $user->set_role($role); return empty($role) ? - new WP_Error('wiaas_authentication_error', 'No Customer permissions!') : + new WP_Error('wiaas_authentication_error', 'No Customer permissions!', array( + 'status' => 403, + )) : $user; } @@ -140,7 +144,9 @@ class Wiaas_Authentication { } if (empty($role)) { - return new WP_Error('wiaas_authentication_error', 'No permissions!'); + return new WP_Error('wiaas_authentication_error', 'No permissions!', array( + 'status' => 403, + )); } update_user_meta($user->ID, '_wiaas_admin_role', $role); @@ -164,7 +170,9 @@ class Wiaas_Authentication { $user->set_role($role); return empty($role) ? - new WP_Error('wiaas_authentication_error', 'No Customer permissions!') : + new WP_Error('wiaas_authentication_error', 'No Customer permissions!', array( + 'status' => 403, + )) : $data; } diff --git a/frontend/src/helpers/HtmlClient.js b/frontend/src/helpers/HtmlClient.js index 2fdc7a5..bb9059c 100644 --- a/frontend/src/helpers/HtmlClient.js +++ b/frontend/src/helpers/HtmlClient.js @@ -96,7 +96,7 @@ class HtmlClient { case '[jwt_auth] incorrect_password': store.dispatch(updateMessages([{ code: 'error', message: `Invalid password!` }])); return; - case '[jwt_auth] wiaas_authentication_error': + case '[jwt_auth] wiaas_authentication_error': case 'wiaas_authentication_error': store.dispatch( { type: LOGOUT, isLoggedIn: false,