/**
  * Login a specific user
  * @param Request $request
  * @param User $user
  * @return \Neuron\Net\Response
  */
 public function login(Request $request, User $user)
 {
     $request->getSession()->set('catlab-user-id', $user->getId());
     $request->getSession()->set('catlab-openid-access-token', $user->getAccessToken());
     $this->trigger('user:login', $user);
     return $this->postLogin($request, $user);
 }
 /**
  * @param User $user
  * @throws InvalidParameter
  * @return \CatLab\OpenIDClient\Models\User
  */
 public function create(User $user)
 {
     // Check for duplicate
     if ($this->getFromEmail($user->getEmail())) {
         throw new InvalidParameter("A user with this email address already exists.");
     }
     $data = $this->prepareFields($user);
     // Insert
     $id = Query::insert($this->table_users, $data)->execute();
     $user->setId($id);
     return $user;
 }