Home | Wiki | OI 1.x Docs | OI 2.x Docs OI logo

NAME

OpenInteract2::Auth::User - Base class for creating OpenInteract users

SYNOPSIS

 # Called by OI2::Auth
 
 my ( $user, $is_logged_in ) =
     OpenInteract2::Auth::User->get_user( $auth );
 print "User ", $user->login_name, " logged in? ", $is_logged_in, "\n";
 print "User ", $auth->user->login_name, " logged in? ", $auth->is_logged_in, "\n";

DESCRIPTION

Handles retrieving a user object. If no user is logged in should still return a user object, just one that isn't persisted to a database.

METHODS

Public Interface

get_user( $auth )

Given $auth (an OpenInteract2::Auth object), returns a user and a flag indicating whether the user is logged in. Here's the process it uses:

At this point if we have a user object we return it with the 'logged-in' flag.

Finally we return the user object and logged-in flag. These are also set in the $auth object.

Overridable Methods

The following methods are overridable by subclasses. Mix and match however you like.

_get_cached_user()

Retrieves the user from a cache. By default this looks in the session, but you can use other means.

Returns: two-item list, user object and user ID.

_set_cached_user( $user )

If a cache is configured saves $user there. Otherwise does nothing.

_get_user_id()

Returns the user ID associated with this session.

_fetch_user( $user_id )

Retrieves the user from permanent storage matching ID $user_id. If the operation fails it should throw an exception.

_fetch_user_failed( $user_id, $error_msg )

Called when _fetch_user() throws an exception or fails to return a user.

_login_user_from_input()

Finds the username from the request field specified in 'login.login_field' and the password from 'login.password_field' and tries to fetch a user by the name and log her in.

If a user is found and authenticated, return the user object. Otherwise return undef.

_check_first_login( $user )

See if $user has logged in for the first time and perform any necessary actions.

_remember_login( $user )

If the value for the request field specified in 'login.remember_field' is set to true then we 'remember' the user by default. This generally means the session won't expire when the user closes her browser.

_create_nologin_user()

Return a transient user object. This object should normally not be saved to the database but created on the fly with a known username and ID. The ID of the theme should be set to 'default_objects.theme'.

COPYRIGHT

Copyright (c) 2002-2003 Chris Winters. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters <chris@cwinters.com>

Generated from the OpenInteract 1.99_03 source.


Home | Wiki | OI 1.x Docs | OI 2.x Docs
SourceForge Logo