PHP code example of mouf / security.userfiledao

1. Go to this page and download the library: Download mouf/security.userfiledao 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/ */

    

mouf / security.userfiledao example snippets


$userFileDao = Mouf::getUserFileDao();

// Let's create the user.
$user = new UserFileBean();
$user->setLogin("david");
// The password is hashed and never appears in cleartext in any file.
$user->setClearTextPassword("my very secret password");
// If you want to add more data, you can store them in the options:
$user->setOptions([ "option1" => 42 ]);

// Let's register the user
$userFileDao->registerUser($user);

// Finally, let's rewrite the users file.
$userFileDao->write();

$userFileDao = Mouf::getUserFileDao();

// Let's remove a user
$userFileDao->removeUser('david');

// Finally, let's rewrite the users file.
$userFileDao->write();

$userFileDao = Mouf::getUserFileDao();

// Check if a user file exists or not
if (!$userFileDao->isUserFileAvailable()) {
	// Do something (maybe redirect the user to a page where he can create a user?)
}