예제 #1
0
 public function deleteUser($userid)
 {
     $loggedInUser = CxSessionHandler::getItem('userid');
     // check if user has permission to delete users
     if (!RoleController::hasRole($loggedInUser, ADMINISTRATOR)) {
         $response_array = array(JsonResponse::P_STATUS => JsonResponse::STATUS_ERROR, JsonResponse::P_MESSAGE => 'You are not authorized to delete users!');
         return $response_array;
     }
     $user_deleted = $this->user->deleteUser($userid);
     if ($user_deleted) {
         // log user out from database level, once delete is succesful
         $authenticator = new AuthenticationController();
         $authenticator->flagUserOffline($userid);
     }
     return $user_deleted;
 }
예제 #2
0
        $change = $authenticator->changePassword($_REQUEST['userid'], $_REQUEST['passcode'], $status);
        if ($change) {
            //DESTROY SESSION TO LOG USER OUT
            CxSessionHandler::destroy();
            //CONSTRUCT RESPONSE
            $response = array();
            $response[P_MESSAGE] = "Password change successful!";
            //SET MESSAGE FOR USER ON NEXT LOGIN
            CxSessionHandler::setViewBag("You just changed your password. Log in again with your new password.");
            //ECHO RESPONSE
            echo JsonResponse::success($response);
            exit;
        } else {
            echo JsonResponse::error("Unable to change password! Please try again.");
            exit;
        }
    } else {
        echo JsonResponse::error('Incomplete request parameters!');
        exit;
    }
} elseif ($intent == "logout") {
    $authenticator = new AuthenticationController();
    $userid = CxSessionHandler::getItem(UserAuthTable::userid);
    $authenticator->flagUserOffline($userid);
    CxSessionHandler::destroy();
    echo JsonResponse::message(STATUS_OK, "Logout successful");
    exit;
} else {
    echo JsonResponse::error('Invalid intent!');
    exit;
}