PHP code example of iscosta77 / auth

1. Go to this page and download the library: Download iscosta77/auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iscosta77 / auth example snippets


use Hermes\Auth\Auth;

$auth = new Auth($db);            // $db = Iscos\Voodoo\Database
$auth->criaTabela();              // cria hermes_users (idempotente)

// Registro
$auth->registrar([
    'nome' => 'Maria',
    'email' => '[email protected]',
    'senha' => 'segredo123',
    'confirmar' => 'segredo123',
]);

// Login / sessão
$auth->login($email, $senha);
if ($auth->verificar()) { /* rota protegida */ }
$auth->exigir();                  // lança se não logado
$auth->logout();

// Senha
$auth->trocarSenha($atual, $nova);
$token = $auth->esqueciSenha($email);          // 64 chars, 30min
$auth->redefinirSenha($token, $novaSenha);     // o app entrega o token