PHP code example of tallieutallieu / dry-accounts

1. Go to this page and download the library: Download tallieutallieu/dry-accounts 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/ */

    

tallieutallieu / dry-accounts example snippets




namespace controller;

class authentication
{
    public static function login(Request $request)
    {
        $login_form = new Form( $request);
        
        $login_form->add_email( 'email', [ 'te() ) {

            if( \Tnt\Account\Facade\Auth::authenticate( $login_form->get( 'email' ), $login_form->get( 'password' ) ) ) {
                $is_logged_in = true;

            } else {
                $auth_failed = true;
            }
        }

        $tpl = new Template();
        $tpl->login_form = $login_form;
        $tpl->auth_failed = $auth_failed;
        $tpl->is_logged_in = $is_logged_in;
        $tpl->render('users/login.tpl');
    }
    
    public static function register(Request $request)
    {
        $app = Application::get();

        $register_form = new Form( $request);

        $register_failed = false;

        $register_form->add_email('email', [
            'ter.tpl');
    }

    public static function logout(Request $request)
    {
        \Tnt\Account\Facade\Auth::logout();

        Response::redirect('login/');
    }
}