/** * @param String $userName * @param String $password * @throws RDException if incorrect username/pw * @return Entity\StudentImpl the student obj */ public function login($userName, $password) { $modelStudent = new Entity\StudentImpl(); $modelStudent->setUserName($userName); $modelStudent->setPassword($password); $studentIter = $this->objectLayer->findStudent($modelStudent); if ($studentIter->size() <= 0) { throw new RDException($string = "Username or Password incorrect"); } else { return $studentIter->current(); } }
/** * Create a new Student object, given the set of initial attribute values. * @param firstName the first name * @param lastName the last name * @param userName the user (login) name * @param password the password * @param emailAddress the email address * @param studentId the student identifier * @param major the student's major * @param address the student's address * @return Entity\StudentImpl a new Student object instance with the given attribute values * @throws RDException in case either firstName, lastName, userName, or studentId is null */ public function createStudent($firstName = null, $lastName = null, $userName = null, $password = null, $emailAddress = null, $studentId = null, $major = null, $address = null) { $aStudent = new Entity\StudentImpl(); // if ($firstName != null && $lastName != null && $userName != null && $password != null && // $emailAddress != null && $studentId != null && $major != null && $address != null) { $aStudent->setFirstName($firstName); $aStudent->setLastName($lastName); $aStudent->setUserName($userName); $aStudent->setPassword($password); $aStudent->setEmailAddress($emailAddress); $aStudent->setStudentId($studentId); $aStudent->setMajor($major); $aStudent->setAddress($address); // } return $aStudent; }
<?php require_once "autoload.php"; use edu\uga\cs\recdawgs\logic\impl\LogicLayerImpl; use edu\uga\cs\recdawgs\entity\impl as Entity; $logicLayer = new LogicLayerImpl(); $userName = trim($_POST['userName']); try { // find admin or student $adminModel = new Entity\AdministratorImpl(); $adminModel->setUserName($userName); $admin = $logicLayer->findAdmin($adminModel, -1)->current(); $studentModel = new Entity\StudentImpl(); $studentModel->setUserName($userName); $student = $logicLayer->findStudent($studentModel, -1)->current(); // reset password $logicLayer->resetPassword($student, $admin); $successMsg = urlencode("Password successfully reset!"); header("Location: ../login.php?status={$successMsg}"); } catch (\edu\uga\cs\recdawgs\RDException $rde) { $error_msg = urlencode($rde->string); header("Location: ../login.php?status={$error_msg}"); } catch (Exception $e) { $errorMsg = urlencode("Unexpected error"); header("Location: ../login.php?status={$errorMsg}"); } exit;