Enable login by role both on frontend and backend #40

Merged
akrdzic merged 6 commits from role-access into master 2018-10-22 11:26:57 +02:00
2 changed files with 13 additions and 5 deletions
Showing only changes of commit 3d6f15dd4f - Show all commits

View File

@@ -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;
}

View File

@@ -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,