public function webservice_authentication($email, $password) { $obj_fnlResult = new returnResult(); $obj_userResult = BL_manageUser::authenticateUser($email, $password); $sessionkey = ""; $isValid = 0; $msg = ""; if ($obj_userResult->type == 0) { $obj_fnlResult->type = 0; $obj_fnlResult->msg = $obj_userResult->msg; } else { $obj_user = $obj_userResult->data; if ($obj_user->userStatus == 1) { $isValid = 1; $errorMsg = $obj_userResult->msg; $sess_result = BL_manageWebService::validateSessionByUserId($obj_user->userId); $obj_fnlResult->type = 1; if ($sess_result->type == 1) { $isValid = 1; $sessionkey = $sess_result->data->sessionKey; $msg = "Successfuly joined to session which already created"; $obj_fnlResult->data = array('validstatus' => $isValid, 'sessionkey' => $sessionkey, 'message' => $msg); } else { $obj_newsessResult = DAL_manageWebService::addNewSessionKey($obj_user->email, $obj_user->userId, BL_manageWebService::generateSessionKey()); if ($obj_newsessResult->type == 1) { $isValid = 1; $sessionkey = $obj_newsessResult->data; $msg = "New session successfuly created"; $obj_fnlResult->data = array('validstatus' => $isValid, 'sessionkey' => $sessionkey, 'message' => $msg); } else { $isValid = 0; $msg = "Problem occured while creating new session"; $obj_fnlResult->data = array('validstatus' => $isValid, 'sessionkey' => $sessionkey, 'message' => $msg); } } } else { if ($obj_user->userStatus == 0) { $isValid = 0; $errorMsg = "Sorry, your account is not verified yet."; $obj_fnlResult->type = 1; } } } return $obj_fnlResult; }
function ValidateSession($sessionKey, $appcode) { $validUId = -1; if (IsValidAppCode($appcode)) { $obj_result = BL_manageWebService::validateSession($sessionKey); if ($obj_result->type == 1) { $validUId = $obj_result->data->userId; } } return $validUId; }