Exemple #1
0
 public function getToken(array $json, $rota, $validade, $acessounico = false, $pessoa = [])
 {
     $token = Data::uid();
     if ($pessoa) {
         $token = strstr($pessoa['email'], '@', true) . "@" . $token;
     }
     $this->db->insert(new \Meister\Meister\Document\Hash(), ["token" => $token, "json" => json_encode($json), "rota" => $rota, "datavalidade" => $validade, "acessounico" => $acessounico, "ativo" => true]);
     return $token;
 }
Exemple #2
0
 public function sessionAction()
 {
     $da = $this->app['auth']->checkToken(Data::getHeader('X-Token'));
     $pessoa = $this->db->doc()->getRepository($this->config['auth']['entity'])->findOneBy(["id" => $da["id"]]);
     if (empty($pessoa)) {
         throw new \Exception(_("Credentials incorrect"), 403);
     }
     $this->app['auth']->setSession($pessoa);
     $this->Render([true]);
 }
Exemple #3
0
 private function getPrefix()
 {
     if (isset($_COOKIE['uid'])) {
         $uidSession = $_COOKIE['uid'];
         setcookie("uid", $uidSession, time() + $this->time);
         $values = $this->cache->getAll($uidSession . '/');
         foreach ($values as $val) {
             $this->cache->expire($val, $this->time);
         }
         return $uidSession . '/';
     }
     $uidSession = Data::uid();
     setcookie("uid", $uidSession, time() + $this->time);
     return $uidSession . '/';
 }
Exemple #4
0
 protected function data($data)
 {
     return Data::serialize($data);
 }
Exemple #5
0
 public function forgotPass($_username)
 {
     // Envia email com alguma coisa para ele.
     $fiedlUser = $this->config["auth"]["field"];
     if (empty($fiedlUser)) {
         $fiedlUser = "******";
     }
     $pessoa = $this->db->doc()->getRepository($this->entity)->findOneBy([$fiedlUser => $_username]);
     if (!$pessoa) {
         throw new \Exception(_('meister_auth_pessoa_nao_encontrada'));
     }
     $pessoa = Data::serialize($pessoa);
     $validade = (new \DateTime())->add(new \DateInterval('PT24H'));
     $token = $this->app['hash']->getToken(["id" => $pessoa['id']], "{$_SERVER['REQUEST_SCHEME']}://" . $_SERVER['HTTP_HOST'] . $this->app['WEB_LINK'] . $this->config['auth']['rotarecover'], $validade, true, $pessoa);
     $data = ["url_retorno" => $_SERVER['HTTP_HOST'] . $this->app['WEB_LINK'] . 'hash/' . $token];
     return $this->app['mail']->sendMail($pessoa['email'], 'Token', $this->app['twig']->render('@{module}/Emails/recoverPass.html.twig', $data), true);
 }