Exemplo n.º 1
0
 /**
  * @param User $user
  * @return array
  */
 private function prepareFields(User $user)
 {
     // Prepare data
     $data = array();
     // Email
     if ($email = $user->getEmail()) {
         $data['u_email'] = $email;
     }
     // Password
     if ($password = $user->getPassword()) {
         $data['u_password'] = password_hash($password, PASSWORD_DEFAULT);
     } else {
         if ($hash = $user->getPasswordHash()) {
             $data['u_password'] = $hash;
         }
     }
     // Username
     if ($username = $user->getUsername()) {
         $data['u_username'] = $username;
     }
     $data['u_emailVerified'] = $user->isEmailVerified() ? 1 : 0;
     return $data;
 }
Exemplo n.º 2
0
 /**
  * Login a specific user
  * @param Request $request
  * @param User $user
  * @param bool $registration
  * @return \Neuron\Net\Response
  */
 public function login(Request $request, User $user, $registration = false)
 {
     // Check for email validation
     if ($this->requiresEmailValidation()) {
         if (!$user->isEmailVerified()) {
             $request->getSession()->set('catlab-non-verified-user-id', $user->getId());
             return Response::redirect(URLBuilder::getURL($this->routepath . '/notverified'));
         }
     }
     $request->getSession()->set('catlab-user-id', $user->getId());
     return $this->postLogin($request, $user, $registration);
 }