public static function getUserCall($userInfo) { $User = new User(); $User->setUserName($userInfo['username']); $User->setUserAge($userInfo['userAge']); return $User->getUser(); }
public function setUserName() { $user = new User(); $response = $user->setUserName(isset($this->data['value']) ? $this->data['value'] : null); $this->updateLoggedUser($response, 'username', $this->data['value']); return json_encode($response); }
/** * Maps a table row to an object * @param array $row * @return User */ protected function mapObject(array $row) { $entry = new User(); $entry->setUserID($row['userID']); $entry->setUserName($row['userName']); $entry->setEmail($row['email']); return $entry; }
function testSetUserName() { //Arrange $user_name = "Barack Obama"; $preferred_style = "IPA"; $region = "Northwest"; $id = 1; $test_user = new User($user_name, $preferred_style, $region, $id); //Act $test_user->setUserName("Miley Cyrus"); $result = $test_user->getUserName(); //Assert $this->assertEquals("Miley Cyrus", $result); }
function test_setUserName() { //Arrange $user_name = "Nathan"; $password = "******"; $longitude = 45.516231; $latitude = -122.682519; $signed_in = true; $id = 1; $test_user = new User($user_name, $password, $longitude, $latitude, $signed_in, $id); //Act $test_user->setUserName($user_name); $result = $test_user->getUserName(); //Assert $this->assertEquals($user_name, $result); }
public function run() { // echo "inside model/run"; $uid = $_POST['login']; $password = MD5($_POST['password']); $po = UserDAOImpl::doLogin($uid, $password); // get from DB /** * 1. no record found * 2. user email and password matched and status is activated * 3. user email and password matched and status is non-activated * 4. exception */ if (null == $po) { $msg = NO_RECORD_PROMPT . BACK_TO_LOGIN_LINK; // header('location: ../login'); } elseif ($po->status == STATUS_ACTIVATED) { $user = new User(); // vo : used to convey user info $user->setId($po->id); $user->setUserName($po->username); $user->setPassword($po->password); $user->setEmail($po->email); $user->setStatus($po->status); $user->setToken($po->token); $user->setTokenExptime($po->token_exptime); $user->setRegTime($po->regtime); Session::init(); Session::set('loggedIn', true); Session::set('user', $user); // header('location: ../dashboard'); $msg = STATUS_LOGIN_SUCCESS; } elseif ($po->status == STATUS_NON_ACTIVATED) { $msg = STATUS_NON_ACTIVATED_PROMPT . BACK_TO_LOGIN_LINK; } else { //header('location: ../login?status=exception'); $msg = "Unknown Exception happened when login."; } return $msg; }
public function propareVO() { // Get data from post $username = stripslashes(trim($_POST['userid'])); // user id $pwd = md5(trim($_POST['pwd'])); $email = trim($_POST['email']); $regtime = R::isoDateTime(); $token = md5($username . $pwd . $regtime); //create activation token $token_exptime = time() + 60 * 60 * 24; //expire time 24 hours // create a vo for convey object info $user = new User(); $user->setUserName($username); $user->setPassword($pwd); $user->setEmail($email); $user->setToken($token); $user->setTokenExptime($token_exptime); $user->setRegTime($regtime); return $user; }
function setUpUserDB() { if (!file_exists(USERDB_FILE_LOCATION)) { $aUserDB = new UserDB(); $aUserDB->setFileName(USERDB_FILE_LOCATION); $aNewUser = new User(); $aNewUser->setUserName("admin"); $aNewUser->setMD5Password("1234"); $aNewUser->setSecurityLevel(0); $aNewUser->setSecurityLevelType(SEC_LEVEL_GREATER_D); $aNewUser->rebuildElementLine(); $aUserDB->addElement($aNewUser); $aNewUser = new User(); $aNewUser->setType(PIN_TYPE_D); $aNewUser->setUserName("pin1"); $aNewUser->setMD5Password("1234"); $aNewUser->setSecurityLevel(0); $aNewUser->setSecurityLevelType(SEC_LEVEL_GREATER_D); $aNewUser->rebuildElementLine(); $aUserDB->addElement($aNewUser); $aUserDB->save(); } }
public function testExecutes_ForkRepositories_ActionWithAListOfRepos() { $groupId = 101; $repo = new GitRepository(); $repos = array($repo); $user = new User(); $user->setId(42); $user->setUserName('Ben'); $path = userRepoPath('Ben', 'toto'); $project = new MockProject(); $projectManager = new MockProjectManager(); $projectManager->setReturnValue('getProject', $project, array($groupId)); $factory = new MockGitRepositoryFactory(); $factory->setReturnValue('getRepositoryById', $repo); $git = TestHelper::getPartialMock('Git', array('definePermittedActions', '_informAboutPendingEvents', 'addAction', 'addView', 'checkSynchronizerToken')); $git->setGroupId($groupId); $git->setProjectManager($projectManager); $git->expectAt(0, 'addAction', array('getProjectRepositoryList', array($groupId))); $git->expectAt(1, 'addAction', array('fork', array($repos, $project, $path, GitRepository::REPO_SCOPE_INDIVIDUAL, $user, $GLOBALS['HTML'], '/plugins/git/?group_id=101&user=42'))); $request = new Codendi_Request(array('repos' => array('1001'), 'path' => 'toto')); $git->setFactory($factory); $git->_doDispatchForkRepositories($request, $user); }
/** * test inserting a user Id profile, editing it, and then updating it */ public function testUpdateValidUser() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("user"); // create a new user Id profile and insert it into mySQL $user = new User(null, $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, $this->VALID_USERACCOUNTTYPE, $this->VALID_USEREMAIL, $this->VALID_USERHASH, $this->VALID_USERNAME, $this->VALID_USERSALT); $user->insert($this->getPDO()); // edit the user Id profile and update it in mySQL $user->setUserName($this->VALID_USERNAME2); $user->update($this->getPDO()); // grab the user data from mySQL and see if the fields match our expected values $pdoUser = User::getUserByUserId($this->getPDO(), $user->getUserId()); $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("user")); $this->assertSame($pdoUser->getBrowser(), $this->VALID_BROWSER); $this->assertEquals($pdoUser->getCreateDate(), $this->VALID_CREATEDATE); $this->assertSame($pdoUser->getIpAddress(), $this->VALID_IPADDRESS); $this->assertSame($pdoUser->getUserAccountType(), $this->VALID_USERACCOUNTTYPE); $this->assertSame($pdoUser->getUserEmail(), $this->VALID_USEREMAIL); $this->assertSame($pdoUser->getUserHash(), $this->VALID_USERHASH); $this->assertSame($pdoUser->getUserName(), $this->VALID_USERNAME2); $this->assertSame($pdoUser->getUserSalt(), $this->VALID_USERSALT); }
public function testUserRepositoryBelongsToUser() { $user = new User(array('language_id' => 1)); $user->setUserName('sandra'); $repo = new GitRepository(); $repo->setCreator($user); $repo->setScope(GitRepository::REPO_SCOPE_INDIVIDUAL); $this->assertTrue($repo->belongsTo($user)); }
} else { require_once './helper/Page.php'; require_once './helper/Context.php'; $page = new Page(); $page->setTitle('Thông Tin Cá Nhân'); $page->addCSS("assets/css/profile.css"); $page->addJavascript("assets/js/jquery.inputmask.bundle.min.js"); $page->startBody(); $update = null; //update PassWord $updatePW = true; date_default_timezone_set('Asia/Bangkok'); $User = new User(); if (isset($_POST["btnUpdate"])) { $User->setUserID($_POST["txtUserID"]); $User->setUserName($_POST["txtUserName"]); $User->setEmail($_POST["txtEmail"]); $dateOfBirth = new DateTime(str_replace('/', '-', $_POST["txtBirthDay"])); //d-m-Y $User->setDateOfBirth($dateOfBirth); $User->setFullName($_POST["txtFullName"]); $User->setGender($_POST["cboGender"]); $User->setUserPermission(0); $userLastModified = new DateTime(); $User->setUserLastModified($userLastModified); $User->setUserPassWord(Context::getCurrentUser()["userPassWord"]); $User->update(); $_SESSION["CurrentUser"] = (array) $User; $update = true; unset($_SESSION['captcha']); } else {
<?php /* Sample Processing of Forgot password form via ajax Page: extra-register.html */ # Response Data Array if (!isset($_SESSION)) { session_start(); } require_once "../entities/User.php"; require_once '../helper/Context.php'; $user = new User(); $resp = array(); // Fields Submitted $user->setUserName($_POST["username"]); $user->setUserPassWord($_POST["password"]); // This array of data is returned for demo purpose, see assets/js/neon-forgotpassword.js $resp['submitted_data'] = $_POST; // Login success or invalid login data [success|invalid] // Your code will decide if username and password are correct $login_status = 'invalid'; $ret = $user->login(); // $ret: true => đăng nhập thành công, $user có đủ thông tin // $ret: false => đăng nhập thất bại if ($ret && $user->getUserPermission() == 1) { $login_status = 'success'; $_SESSION["IsLogin"] = 1; // đã đăng nhập $_SESSION["CurrentUser"] = (array) $user; }
case "disable": $users[$_GET['line']]->setEnabled(false); $mustSave = true; break; case "edit": $tpl_edit = new Template(TPL_FILE_LOCATION . 'users_edit.tpl'); $tpl_edit->set('lang', $lang); $tpl_edit->set('theUser', $users[$_GET['line']]); $tpl_edit->set('config', $config); $tpl_body->set('form', $tpl_edit); break; case "add": $anUser = new User(); $anUser->setType($_POST["type"]); if ($_POST["type"] == PIN_TYPE_D) { $anUser->setUserName($userDB->getNextPINName()); } else { $anUser->setUserName($_POST["username"]); } $anUser->setSecurityLevel(intval($_POST["seclevel"])); $anUser->setSecurityLevelType($_POST["secleveltype"]); $anUser->setMD5Password($_POST["password"]); $anUser->rebuildElementLine(); $userDB->addElement($anUser); $mustSave = true; break; case "save": $users[$_POST["line"]]->setType($_POST["type"]); if ($_POST["type"] == PIN_TYPE_D && $_POST["username"] != $users[$_POST["line"]]->getUserName()) { $users[$_POST["line"]]->setUserName($userDB->getNextPINName()); } else {
$_SESSION["token"] = $security; $token = "token=" . $encrypted; } else { $encrypted = $crypter->Encrypt($_SESSION["token"]); $token = "token=" . $encrypted; } } $user = new User(); //Chuyen trang khac neu da dang nhap /*if (Context::IsLogged()) { Utils::Redirect("index.php"); }*/ $boardLogin = true; $mess = ""; if (isset($_POST["btnLogin"])) { $user->setUserName($_POST["login_txtUserName"]); $user->setUserPassWord($_POST["login_txtPassWord"]); $remember = isset($_POST['chkRemember']) ? true : false; $ret = $user->login(); // $ret: true => đăng nhập thành công, $user có đủ thông tin // $ret: false => đăng nhập thất bại if ($ret) { $_SESSION["IsLogin"] = 1; // đã đăng nhập $_SESSION["CurrentUser"] = (array) $user; // ghi nho dang nhap if ($remember) { $expire = time() + 15 * 24 * 60 * 60; setcookie("UserName", $user->getUserName(), $expire); } $url = "index.php";
function account_create($loginname = '', $pw = '', $ldap_id = '', $realname = '', $register_purpose = '', $email = '', $status = 'P', $confirm_hash = '', $mail_site = 0, $mail_va = 0, $timezone = 'GMT', $lang_id = 'en_US', $unix_status = 'N', $expiry_date = 0) { $um = UserManager::instance(); $user = new User(); $user->setUserName($loginname); $user->setRealName($realname); $user->setPassword($pw); $user->setLdapId($ldap_id); $user->setRegisterPurpose($register_purpose); $user->setEmail($email); $user->setStatus($status); $user->setConfirmHash($confirm_hash); $user->setMailSiteUpdates($mail_site); $user->setMailVA($mail_va); $user->setTimezone($timezone); $user->setLanguageID($lang_id); $user->setUnixStatus($unix_status); $user->setExpiryDate($expiry_date); $u = $um->createAccount($user); if ($u) { return $u->getId(); } else { return $u; } }
public function populateObject($rsItem) { $seq_ = $rsItem["seq"]; $fullname = $rsItem["fullname"]; $username_ = $rsItem["username"]; $password_ = $rsItem["password"]; $emailId_ = $rsItem["emailid"]; $dateOfRegistration_ = $rsItem["dateofregistration"]; $isActive_ = $rsItem["isactive"]; $isManager_ = $rsItem["ismanager"]; $locationSeq_ = $rsItem["locationseq"]; $folderSeq_ = $rsItem["folderseq"]; $locationName_ = $rsItem["locationName"]; $mobile_ = $rsItem["mobile"]; $user = new User(); $user->setSeq($seq_); $user->setFullName($fullname); $user->setUserName($username_); $user->setPassword($password_); $user->setDecodedPassword(SecurityUtil::Decode($password_)); $user->setEmailId($emailId_); $user->setDateOfRegistration($dateOfRegistration_); $user->setConfirmPassword($password_); $user->setIsActive($isActive_); $user->setIsManager($isManager_); $user->setLocationSeq($locationSeq_); $user->setFolderSeq($folderSeq_); $user->setLocationName($locationName_); $user->setMobile($mobile_); $otherLocationSeqs = $this->getLocationUsersLocationSeqs($user->getSeq(), $locationSeq_); $user->setOtherLocationSeqs($otherLocationSeqs); return $user; }
<?php require_once "../DataStoreMgr/UserDataStore.php"; require_once "../BusinessObjects/User.php"; $user = new User(); $user->setUserName("baljeet"); $user->setEmailId("*****@*****.**"); $user->setIsActive(true); $user->setPassword("aa"); $UDS = new UserDataStore(); $UDS->Save($user);
/* @var $User User */ if ($UserID) { $Users = User::GetUsers(new UserSearchParameters($UserID)); if ($Users) { $User = $Users[0]; } else { header('location:index.php'); exit; } $_SESSION['UserSalt'] = $User->getSalt(); } else { $User = new User(NULL, $lang->g('LabelNewUser')); } if (array_key_exists('hidAction', $_POST) && $_POST['hidAction'] == 'UserView') { if (array_key_exists('txtUserName', $_POST)) { $User->setUserName(Utils::NullIfEmpty($_POST['txtUserName'])); } if (array_key_exists('hidPassword', $_POST)) { $User->setPassword(Utils::NullIfEmpty($_POST['hidPassword'])); $User->setSalt(Utils::NullIfEmpty($_SESSION['UserSalt'])); } $User->setFirstName(Utils::NullIfEmpty($_POST['txtFirstName'])); $User->setInsertion(Utils::NullIfEmpty($_POST['txtInsertion'])); $User->setLastName(Utils::NullIfEmpty($_POST['txtLastName'])); $User->setEmailAddress(Utils::NullIfEmpty($_POST['txtEmailAddress'])); $User->setLanguage(Utils::NullIfEmpty($_POST['selectLanguage'])); $User->setDateDisplayOptions($_POST['selectDateformat']); $User->setImageview(Utils::NullIfEmpty($_POST['selectImageview'])); if ($CurrentUser->hasPermission(RIGHT_USER_RIGHTS)) { $getrights = array(); foreach (Rights::getDefinedRights() as $k => $v) {
<?php require_once "UserPDO.php"; require_once "User.php"; if (isset($_POST['submit'])) { $username = $_POST["username"]; // echo $username . "<br>\n"; $password = $_POST["password"]; //echo $password ."<br>\n"; if ($username != '' && $password != '') { $userPDO = new UserPDO(); $user = new User(); $user->setUserName($username); $user->setPassword($password); $loggedIn = $userPDO->checkUserExists($user); echo "<html>"; echo "<head>"; echo "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' >"; echo "<link rel='stylesheet' type='text/css' href='menu.css'>"; echo "<title>News Portal -User Login</title>"; echo "</head>"; echo "<body>"; if ($loggedIn) { include "menu.php"; echo "User LoggedIn </br>"; echo "Welcome to Nuntium Home"; } else { echo "User Not LoggedIn </br>"; echo "<a href='index.php'> Go to Home</a>"; } echo "</body>";
/** * Create user account based on LDAP info. * * @param String $eduid * @param String $uid * @param String $cn * @param String $email * @return User */ function createAccount($eduid, $uid, $cn, $email) { if (trim($uid) == '' || trim($eduid) == '') { return false; } $user = new User(); $user->setUserName($this->generateLogin($uid)); $user->setLdapId($eduid); $user->setRealName($cn); $user->setEmail($email); // Generates a pseudo-random password. Its not full secure but its // better than nothing. $user->setPassword(md5((string) mt_rand(10000, 999999) . time())); // Default LDAP $user->setStatus($this->getLdap()->getLDAPParam('default_user_status')); $user->setRegisterPurpose('LDAP'); $user->setUnixStatus('S'); $user->setTimezone('GMT'); $user->setLanguageID($GLOBALS['Language']->getText('conf', 'language_id')); $um = $this->getUserManager(); $u = $um->createAccount($user); if ($u) { // Create an entry in the ldap user db $ldapUserDao = $this->getDao(); $ldapUserDao->createLdapUser($u->getId(), 0, $uid); return $u; } return false; }
function testUpdate() { $user_name = "Wolf"; $user_buy_quantity = 5; $user_phone = '1234567890'; $user_email = "*****@*****.**"; $activity_id = 100; $id = 1; $test_user = new User($user_name, $user_buy_quantity, $user_phone, $user_email, $activity_id, $id); $test_user->save(); $test_user->setUserName("Wolfy"); $test_user->update(); $result = User::getAll(); $this->assertEquals($test_user, $result[0]); }
public function parseUser($userObject) { $user = new User(); $user->setId($userObject->id); $user->setFirstName($userObject->first_name); if (property_exists($userObject, 'last_name')) { $user->setLastName($userObject->last_name); } if (property_exists($userObject, 'username')) { $user->setUserName($userObject->username); } return $user; }
public function getUsers() { $connection = parent::connect(); $selectSQL = "SELECT * FROM USER"; $rows = $connection->query($selectSQL); $users = array(); foreach ($rows as $row) { $user = new User(); $user->setUserId($row[0]); $user->setUserName($row[1]); $user->setPassword($row[2]); $users[] = $user; } parent::disconnect($connection); return $users; }
/** * Crear el usuario admin de sysPass. * Esta función crea el grupo, perfil y usuario 'admin' para utilizar sysPass. * * @throws SPException */ private static function createAdminAccount() { // Datos del grupo Groups::$groupName = "Admins"; Groups::$groupDescription = "Admins"; if (!Groups::addGroup()) { self::rollback(); throw new SPException(SPException::SP_CRITICAL, _('Error al crear el grupo "admin"'), _('Informe al desarrollador')); } $User = new User(); // Establecer el id de grupo del usuario al recién creado $User->setUserGroupId(Groups::$queryLastId); $Profile = new Profile(); $Profile->setName('Admin'); $Profile->setAccAdd(true); $Profile->setAccView(true); $Profile->setAccViewPass(true); $Profile->setAccViewHistory(true); $Profile->setAccEdit(true); $Profile->setAccEditPass(true); $Profile->setAccDelete(true); $Profile->setConfigGeneral(true); $Profile->setConfigEncryption(true); $Profile->setConfigBackup(true); $Profile->setMgmCategories(true); $Profile->setMgmCustomers(true); $Profile->setMgmUsers(true); $Profile->setMgmGroups(true); $Profile->setMgmProfiles(true); $Profile->setEvl(true); if (!$Profile->profileAdd()) { self::rollback(); throw new SPException(SPException::SP_CRITICAL, _('Error al crear el perfil "admin"'), _('Informe al desarrollador')); } // Datos del usuario $User->setUserLogin(self::$_username); $User->setUserPass(self::$_password); $User->setUserName('Admin'); $User->setUserProfileId($Profile->getId()); $User->setUserIsAdminApp(true); $User->setUserIsAdminAcc(false); $User->setUserIsDisabled(false); if (!$User->addUser()) { self::rollback(); throw new SPException(SPException::SP_CRITICAL, _('Error al crear el usuario "admin"'), _('Informe al desarrollador')); } // Guardar el hash de la clave maestra ConfigDB::setCacheConfigValue('masterPwd', Crypt::mkHashPassword(self::$_masterPassword)); ConfigDB::setCacheConfigValue('lastupdatempass', time()); ConfigDB::writeConfig(true); if (!$User->updateUserMPass(self::$_masterPassword)) { self::rollback(); throw new SPException(SPException::SP_CRITICAL, _('Error al actualizar la clave maestra del usuario "admin"'), _('Informe al desarrollador')); } }
$ERRORS[] = 'Invalid age specified.'; } if (in_array($USER['gender'], array_keys($GENDER)) == false) { $ERRORS[] = 'Invalid gender specified.'; } if ($USER['email'] == null) { $ERRORS[] = 'E-mail address was blank.'; } elseif (preg_match('/^[a-z0-9_+.]{1,64}@([a-z0-9-.]*){1,}\\.[a-z]{1,5}$/i', $USER['email']) == false) { $ERRORS[] = 'Invalid e-mail address specified.'; } if (sizeof($ERRORS) > 0) { draw_errors($ERRORS); } else { // Create an user and set some base attrs. $new_user = new User($db); $new_user->setUserName($USER['user_name']); $new_user->setRegisteredIpAddr($_SERVER['REMOTE_ADDR']); $new_user->setPassword($USER['password']); $new_user->setCurrentSaltExpiration($new_user->sysdate()); $new_user->setLastActivity($new_user->sysdate()); $new_user->setAccessLevel('user'); $new_user->setEmail($USER['email']); $new_user->setAge($USER['age']); $new_user->setGender($USER['gender']); $new_user->setProfile($USER['profile']); $new_user->setCurrency($APP_CONFIG['starting_funds']); $new_user->setUserTitle('User'); $new_user->setTextareaPreference('tinymce'); $new_user->setDatetimeCreated($new_user->sysdate()); $new_user->setDatetimeLastPost($new_user->sysdate()); $new_user->setPasswordResetRequested($new_user->sysdate());
<?php // handle login //var_dump($_POST); include_once "classes/user.php"; $user = new User(); $user->setUserName($_POST['username']); $user->setUserPassword($_POST['password']); $user->login();