public function getPassword(UserEntity $user) { if ($user->getAuthentification() == UserModel::AUTHENTIFICATION_BY_PASSWORD) { $password = new PasswordEntity($user); return $password->getPassword(); } return false; }
/** * Add a role to a given user * * @param UserEntity $user * @param string $role name of the role to add */ public function addRoleForUser(UserEntity $user, $role) { $roles = $user->getRoles(); if (!in_array($role, $roles)) { $this->userRolePivotMapper->addRoleForUser($user->getId(), $role); array_push($roles, $role); $user->setRoles($roles); } }
public function get_by_username($username) { $tmp = $this->db->select_row('SELECT id, username FROM users WHERE username = "******"'); $entity = null; if (!empty($tmp)) { $entity = new UserEntity(); $entity->setId($tmp['id']); $entity->setUsername($tmp['username']); } return $entity; }
public function getByUser(UserEntity $user) { $db = new Database(); $result = $db->execute("SELECT * FROM passwords WHERE account = ?", array($user->getId()))->fetch(); if ($result) { $password = new PasswordEntity(); $password->setId($result['id']); $password->setUser($result['account']); $password->setPassword($result['password']); return $password; } return null; }
public function edit() { $users_collection = new UsersCollection(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $user = new UserEntity(); $user->setId($_GET['id']); $user->setUsername($_POST['username']); $user->setPassword($_POST['password']); $users_collection->save($page); header('Location: index.php?controller=users'); } $users = $users_collection->get($_GET['id']); $this->loadView('cms/users_edit', array('users' => $users)); }
public function validateLogin($username, $password) { global $gMessage; if (empty($username) || empty($password)) { $gMessage = "Invalid User Name Or Password"; return false; } $user = new UserEntity(); if ($user->login($username, $password)) { $this->userInfo = $user->info; $this->setSessionData(); return true; } $gMessage = "Invalid User Name Or Password"; return false; }
public function updateSubscription($userID, $subscriptionID) { $userEntity = UserEntity::userInstance(); $userEntity->subscription_id = $subscriptionID; $this->db->where("ID", $userID); if ($this->db->update("wp_server_users", $userEntity)) { $this->returnData->result = true; return $this->returnData; } else { $this->returnData->error = new ConstExceptionCode(ConstExceptionCode::UNKNOWN_ERROR_CODE); return $this->returnData; } }
public static function setUserValues($userEntity) { if (self::$singleton_instance === null) { self::$singleton_instance = new UserEntity(); } self::$singleton_instance->first_name = isset($userEntity->first_name) ? $userEntity->first_name : self::$singleton_instance->first_name; self::$singleton_instance->last_name = isset($userEntity->last_name) ? $userEntity->last_name : self::$singleton_instance->last_name; // self::$singleton_instance->user_name = isset($userEntity->user_name) ? $userEntity->user_name : self::$singleton_instance->user_name; self::$singleton_instance->user_type = isset($userEntity->user_type) ? $userEntity->user_type : ''; self::$singleton_instance->subscription_id = isset($userEntity->subscription_id) ? $userEntity->subscription_id : ''; // self::$singleton_instance->password = isset($userEntity->password) ? $userEntity->password : self::$singleton_instance->password; self::$singleton_instance->is_active = isset($userEntity->is_active) ? $userEntity->is_active : true; self::$singleton_instance->email_id = isset($userEntity->email_id) ? $userEntity->email_id : self::$singleton_instance->email_id; }
public function getPayment($planID, $token) { $serviceResponse = new ServiceResponse(); $user = $this->GetSessionUser($token); if ($user->IsSuccess) { $userDetail = UserEntity::where('UserID', $user->Data->UserID)->first(); if ($userDetail->IsVerified) { $serviceResponse = $this->DataProvider->PaymentDetails($planID); if ($serviceResponse->IsSuccess) { $amount = $serviceResponse->Data->PaidAmount; $data = array('amount' => $amount, 'fullname' => $user->Data->FirstName . ' ' . $user->Data->LastName, 'email' => $user->Data->Email, 'mobile' => $user->Data->Mobile, 'productInfo' => 'This is the product info', 'planID' => $planID, 'userID' => $user->Data->UserID); return View::make('payment.detail')->with($data); } } else { $serviceResponse->IsSuccess = true; $serviceResponse->Data = $userDetail; $serviceResponse->ErrorCode = Constants::$MobileNotVerified; $serviceResponse->Message = trans("messages.MobileNotEnabled"); } } else { $serviceResponse = $user; return $this->GetJsonResponse($serviceResponse); } }
/** * @param UserEntity $userEntity * @param array $parameters */ public function updateUser(UserEntity $userEntity, array $parameters) { $options = [UserValidator::OPTION_SKIP_PASSWORD_VALIDATION]; //todo : refactored this : $parameters = array_merge($userEntity->toArray(), $parameters); if ($userEntity->getEmail() === $parameters['email']) { $options[] = UserValidator::OPTION_SKIP_EMAIL_UNIQUENESS; } $this->getUserValidator()->validateParameters($parameters, $options); if ($userEntity->getEmail() !== $parameters['email']) { $userEntity->setPendingEmail($parameters['email']); (new EmailConfirmationController($this->getContainer()))->emailUpdated($userEntity); } $userEntity->setName($parameters['name'])->setPhone($parameters['phone']); $this->getEntityManager()->persist($userEntity); $this->getEntityManager()->flush($userEntity); }
function bindUserDto($userDto) { if ($userDto != null) { $userEntity = new UserEntity(); $userEntity->setUserId($userDto->getUserId()); $userEntity->setUserEmail($userDto->getUserEmail()); $userEntity->setUserPassword($userDto->getUserPassword()); $userEntity->setUserName($userDto->getUserName()); $userEntity->setUserSurname($userDto->getUserSurname()); $userEntity->setUserNumber($userDto->getUserNumber()); $userEntity->setUserGender($userDto->getUserGender()); $userEntity->setUserAge($userDto->getUserAge()); $userEntity->setUserAllowPush($userDto->getUserAllowPush()); return $userEntity; } else { return null; } }
/** * Expire a refresh token * * @param string $refreshToken * @param UserEntity $user */ protected function expireRefreshToken($refreshToken, $user) { $token = $this->refreshTokenMapper->findBy(['refresh_token' => $refreshToken, 'user_id' => $user->getId()]); if (!$token) { throw new OutOfBoundsException('Refresh token not found.'); } $token->setExpires(date("Y-m-d H:i:s", time())); $this->refreshTokenMapper->update($token); }
public function updateProfile($userID) { $this->db->trans_start(); $newUserEntity = new stdClass(); $newUserEntity->email_id = $this->input->post('email_id'); $newUserEntity->first_name = $this->input->post('first_name'); $newUserEntity->last_name = $this->input->post('last_name'); // $newUserEntity->is_active = $this->input->post('is_active'); // $newUserEntity->password = $this->input->post('password'); // $newUserEntity->subscription_id = $this->input->post('subscription_id'); // $newUserEntity->user_name = $this->input->post('user_name'); // $newUserEntity->user_type = $this->input->post('user_type'); $this->db->where("ID", $userID, false); if ($this->db->update("wp_server_users", $newUserEntity)) { UserEntity::setUserValues($newUserEntity); if ($this->updateUserDetail($userID)) { $user_type = $this->getUserType($userID); if ($user_type && strcmp($user_type, 'operator') == 0) { $this->load->model("Operator_model"); if ($this->Operator_model->addOperator($userID)) { return parent::returnData(true); } } else { $this->load->model("Driver_model"); if ($this->Driver_model->addDriver($userID)) { return parent::returnData(true); } } } } $this->db->trans_complete(); if ($this->db->trans_status() === FALSE) { return parent::returnData(false, ConstExceptionCode::DATA_NOT_SAVED); } return parent::returnData(false, ConstExceptionCode::UNKNOWN_ERROR_CODE); }
<?php require '../../../vendor/autoload.php'; require '../Resources/User/Mapper/User.php'; use Xeeo\Services\Database\Mongo\Mapper as MongoMapper, Xeeo\Services\Authenticate\AuthenticateApi; $authApi = AuthenticateApi::getInstance(); MongoMapper::addConnection(array('name' => 'connectionName', 'url' => 'mongodb://localhost:27017/databaseName')); $user = new \UserEntity(); $user->setField('name', 'Raul Geana'); $user->setField('status', 'pending'); $addresses = new \Xeeo\Services\Core\Abstracts\Collection(); $address = new \UserAddress(); $address->setField('city', 'Timisoara'); $address->setField('str', 'Borsec'); $addresses[] = $address; $address = new \UserAddress(); $address->setField('city', 'New York'); $address->setField('str', 'Times Square'); $addresses[] = $address; $address = new \UserAddress(); $address->setField('city', 'Munchen'); $address->setField('str', 'Leopold Strasse'); $addresses[] = $address; $addresses->removeEntities(function ($entity) { return $entity->getField('city') == 'Timisoara'; }); $user->setField('addresses', $addresses); $personalInfo = new \UserPersonalInfo(); $personalInfo->setField('address', 'some fake address'); $personalInfo->setField('jobs', array('developer', 'cto')); $credentials = new \UserCredentials();
<?php require '../../../vendor/autoload.php'; require '../Resources/User/Mapper/User.php'; $user = new \UserEntity(); $userArray = array('name' => "Raul", 'personalInfo' => array('address' => "StartupHub", 'jobs' => "Trainer"), 'status' => "active"); $user->populateFromArray($userArray); var_dump($user);
} else { if ($_GET['go'] == 'reset_password_submit') { $user = new UserEntity(); $user->resetPassword(); } else { if ($_GET['go'] == 'login_submit') { $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; if ($gSession->validateLogin($username, $password)) { $info = $gRouteInfo['home']; } else { $info = $gRouteInfo['login']; } } else { if ('profile_change_submit' == $_GET['go']) { $user = new UserEntity(); $gSession->reloadSession($user->changeProfile($gSession->userInfo['email'])); } } } } //print_r($gSession->userInfo);// "logout happening..."; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Mindspace SEO Tool</title> <link rel="stylesheet" type="text/css" href="template/css/analyzer.css" /> <link rel="stylesheet" type="text/css" href="template/css/layout.css" />
function bindUserDto($userDto) { if ($userDto != null) { global $entityManager; $userEntity = new UserEntity(); $userEntity->setUserId($userDto->getUserId()); $userEntity->setEmail($userDto->getEmail()); $userEntity->setPassword($userDto->getPassword()); $userEntity->setName($userDto->getName()); $userEntity->setSurname($userDto->getSurname()); $userEntity->setPhone($userDto->getPhone()); $userEntity->setGender($userDto->getGender()); $userEntity->setAge($userDto->getAge()); $userEntity->setUserAllowPush($userDto->getUserAllowPush()); return $userEntity; } else { return null; } }
public function logout() { $this->session->sess_destroy(); UserEntity::setDefault(); redirect('User/login'); }