Auth

Auto Modeler comes with two Auth drivers, one for Auto_Modeler_Core, and one for Auto_Modeler_ORM_Core.

To use one, change your Auth's config file to use either "AutoModeler" or "AutoModelerORM" for the driver you wish to use.

AutoModeler Driver

The AutoModeler driver does not support roles at all because it lacks the relationships. Below is some sample code that you might use to create a user and then login:

$user = new User_Model();
$user->username = 'Foo';
$user->password = 'Baz'; // User model automatically hashes the password for you.
$user->save();

// Now to login
if (Auth::instance()->login('Foo', 'Baz'))
    url::redirect('user/profile');
else
    url::redirect('user/failed_login');

in order to revoke a user's login, you must delete the user. This is a very basic auth system if you do not use ORM.

AutoModelerORM Driver

The ORM driver is similar to the non ORM driver, except it uses roles to track who can do what. The minimum role is 'login'. All users must have this role to login. Any additional roles are just that: additional and specific to your application. Here's some code you might use:

$user = new User_Model();
$user->username = 'Foo';
$user->password = 'Baz'; // User model automatically hashes the password for you.
$user->save();

$user->roles = 1; // This is the login role's ID in the database.

// Now to login
if (Auth::instance()->login('Foo', 'Baz'))
    url::redirect('user/profile');
else
    url::redirect('user/failed_login');

// You can also check for specific roles for a user. This uses basic Auto_Modeler_ORM methods:
$can_login = Auto_Modeler_ORM::factory('user', 'Foo')->has('role', 'login');

// Or you can check if the currently logged in user has a specific role:
$is_admin = Auth::instance()->logged_in('admin');