Exemple #1
0
 /**
  * @param $username
  * @param $realname
  * @param $password
  * @param $email
  * @return Models\User
  */
 public function createUser($username, $realname, $password, $email)
 {
     $user = new Models\User();
     $user->username = $username;
     $user->displayname = $realname;
     $user->setPassword($password);
     $user->created = date("Y-m-d H:i:s");
     $user->email = $email;
     $user->save();
     return $user;
 }
Exemple #2
0
 public function testPasswordRehash()
 {
     $oldHash = '$1$tc6CkLWy$4m956zmpQEUd5hvLEdNRC.';
     //;
     $user = new User();
     $user->username = $this->faker->userName;
     $user->displayname = $this->faker->name();
     $user->password = $oldHash;
     $this->assertTrue($user->checkPassword('rasmuslerdorf'), "Check password worked from the old hash");
     $this->assertNotEquals($oldHash, $user->password, "Check the password hash had changed");
     $this->assertTrue($user->checkPassword('rasmuslerdorf'), "Check new hashed password works too.");
 }
Exemple #3
0
 /**
  * @return User|false
  */
 public function getUser()
 {
     if (!$this->_user) {
         $this->_user = User::search()->where('user_id', $this->user_id)->execOne();
     }
     return $this->_user;
 }
Exemple #4
0
 public function findUserByUUID($uuid)
 {
     $user = Models\User::search()->where('user_uuid', $uuid)->execOne();
     if (!$user) {
         throw new TigerException("Cannot find User by UUID");
     }
     return $user;
 }
 public function dashboard()
 {
     $user = Models\User::getCurrent();
     if ($user instanceof Models\User) {
         $this->slim->render('dashboard/dashboard.phtml', array());
     } else {
         $this->slim->redirect("/");
     }
 }
 public function logout()
 {
     $user = Models\User::getCurrent();
     if ($user instanceof Models\User) {
         TigerApp::log("Logout for {$user->username}");
     }
     Session::dispose('user');
     $this->slim->response()->redirect("/login");
 }
 public function index()
 {
     $user = Models\User::getCurrent();
     $this->slim->log->debug("Index page accessed from {$this->slim->request()->getIp()}");
     if ($user instanceof Models\User) {
         $this->slim->response()->redirect("/dashboard");
     } else {
         $this->slim->render('home/home.phtml', array());
     }
 }
 public function doUpload()
 {
     Models\User::checkLoggedIn();
     $user = Models\User::getCurrent();
     if ($user instanceof Models\User) {
         $imageService = new ImageService();
         $imageService->uploadImage($user, $_FILES['file']);
     } else {
         $this->slim->notFound();
     }
 }
Exemple #9
0
 public function tearDown()
 {
     if (isset($this->testUser) && $this->testUser instanceof User) {
         $this->testUser->delete();
     }
 }
 public function testCreateImageWithCreaterUpdater()
 {
     $mockAsset = __DIR__ . "/../Assets/sample-1.jpg";
     $mockUpload = $this->makeMockUpload($mockAsset);
     $this->testUser->save();
     User::setCurrent($this->testUser);
     $image = $this->imageService->uploadImage($this->testUser, $mockUpload);
     $image->save();
     $this->assertEquals($this->testUser->user_id, $image->getCreatedUser()->user_id);
     $this->assertEquals($this->testUser->user_id, $image->getUpdatedUser()->user_id);
 }