Exemplo n.º 1
0
 public static function testFindOne($uid, $password)
 {
     $user = UserDAOImpl::doLogin($uid, $password);
     if (null == $user) {
         echo "no matched record";
     } else {
         echo $user->uid . " \t " . $user->password . " \t " . $user->age . "\n";
     }
 }
Exemplo n.º 2
0
 public function activateAccount($token)
 {
     $isActivated = UserDAOImpl::activateAccount(stripslashes(trim($token)), time());
     if ($isActivated) {
         $msg = SIGN_UP_ACTIVATE_SUCCESS;
     } else {
         $msg = SIGN_UP_ACTIVATE_CODE_EXPIRED;
     }
     return $msg;
 }
Exemplo n.º 3
0
 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;
 }