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
Showing only changes of commit 09aac81276 - Show all commits

View File

@@ -47,7 +47,7 @@ class Wiaas_Authentication {
*/
public static function authenticate_current_user($user_id) {
// do nothing if user not authenticated, user is super admin or this is REST API request
if (! $user_id || $user_id === self::SUPER_ADMIN_USER_ID) {
if (! $user_id || (int) $user_id === self::SUPER_ADMIN_USER_ID) {
return $user_id;
}
@@ -168,9 +168,7 @@ class Wiaas_Authentication {
public static function authenticate_rest_user_on_login($data, $user) {
// if admin do nothing
if ($user->ID === self::SUPER_ADMIN_USER_ID) {
return new WP_Error('wiaas_authentication_error', 'No Customer permissions!', array(
'status' => 403,
));
return $data;
}
$role = user_can($user->ID, 'wiaas_customer') ? 'customer' : '';
$user->set_role($role);