Inheritance: extends Model, use trait Components\Model\Traits\Timestampable, use trait Components\Model\Traits\SoftDeletable
Esempio n. 1
0
 /**
  * GET | Redirect the user if the 'users' table is empty or not
  * then redirect it to either login or registration.
  *
  * @return mixed
  */
 public function trySampleForms()
 {
     if (User::count()) {
         return redirect()->to(route('showLoginForm'))->withInfo(lang()->get('responses/login.pre_flash_message'));
     }
     return redirect()->to(route('showRegistrationForm'))->withInfo(lang()->get('responses/register.pre_flash_message'));
 }
 private function _getUser($id)
 {
     $user = User::findFirst($id);
     if ($user === false) {
         return redirect(route('daison_showUsers'))->withError("User id [{$id}] not found.");
     }
     return $user;
 }
 public function testLogin()
 {
     if (!User::count()) {
         $this->testRegistration();
     }
     $this->triggerWelcomeProcess();
     # LOGIN
     $this->assertEquals('200', $this->session->getStatusCode());
     // === 200
     $this->assertContains($this->url . '/auth/login', $this->session->getCurrentUrl());
     // === $this->url.'auth/register'
     $login_page = $this->session->getPage();
     $login_btn = $login_page->find('named', ['id', 'login-btn']);
     $login_page->fillField('email', $this->email);
     $login_page->fillField('password', $this->password);
     $login_btn->press();
     // $login_page->pressButton('login-btn');
     sleep(5);
     $this->assertContains($this->url . '/newsfeed', $this->session->getCurrentUrl());
     // === $this->url.'newsfeed'
 }
Esempio n. 4
0
 /**
  * GET | This activates a user record to be able to login.
  *
  * @return mixed
  */
 public function activateUser($token)
 {
     $user = User::find(['token = :token: AND activated = :activated:', 'bind' => ['token' => $token, 'activated' => false]])->getFirst();
     if (!$user) {
         flash()->session()->warning('We cant find your request, please ' . 'try again, or contact us.');
         return view('errors.404');
     }
     $user->setActivated(true);
     if ($user->save() === false) {
         foreach ($user->getMessages() as $message) {
             flash()->session()->error($message);
         }
     } else {
         flash()->session()->success('You have successfully activated your account, ' . 'you are now allowed to login.');
     }
     return redirect()->to(route('showLoginForm'));
 }
Esempio n. 5
0
 public function activateUserAction($token)
 {
     $user = User::find(['token = :token: AND activated = :activated:', 'bind' => ['token' => $token, 'activated' => false]])->getFirst();
     # - return 404, if the condition not found
     if (!$user) {
         FlashBag::warning('We cant find your request, please ' . 'try again, or contact us.');
         return View::make('errors.404');
     }
     # - activate the user
     $user->setActivated(true);
     # - if user fails to save, show an error
     if ($user->save() === false) {
         foreach ($user->getMessages() as $message) {
             FlashBag::error($message);
         }
     } else {
         FlashBag::success('You have successfully activated your account, ' . 'you are now allowed to login.');
     }
     # - then redirect the user with the success message
     return Redirect::to(URL::route('showLoginForm'));
 }