NAME
Konstrukt::Plugin::usermanagement::basic - Basic user management.
SYNOPSIS
Tag interface
<!-- example for a page for basic user management.
"login, register, sendpass, changepass" is the default, so you can
also omit the "show"-attribute. -->
<& usermanagement::basic show="login, register, sendpass, changepass" / &>
<!-- only show login -->
<& usermanagement::basic show="login" / &>
Perl interface
my $user_basic = use_plugin 'usermanagement::basic' or die;
my $id = $user_basic->id(); #will return the user's id, if logged in. 0 otherwise
$user_basic->data($id); #will return { email => ..}
#of the user with the given id
$user_basic->email($id); #will return the users email address
#...
DESCRIPTION
This Konstrukt plugin provides basic user management functionality.
It will care for persistence by using the Konstrukt session management and it allows other plugins to access basic user data like the users id, if logged in.
my $user_basic = use_plugin 'usermanagement::basic' or die;
my $id = $user_basic->id(); #will return the user's id, if logged in. 0 otherwise
$user_basic->data($id); #will return { email => ..}
#of the user with the given id
$user_basic->email($id); #will return the users email address
It may also be used for user athentication on your website to provide log-in/ log-out-screens etc:
<& usermanagement::basic show="login, register, sendpass, changepass" / &>
The "login"-form will enable the user to log in with its email/password if not logged in or a log-off button otherwise.
The "register"-form will enable the user to register itself with its email for the service. A random password will be generated and sent to the given email address.
The "sendpass"-form will enable the user to get its password sent to its email address.
The "changepass"-form will enable the user to change its password.
Disabling some forms will let you split the forms into several pages.
EVENTS
This plugin triggers these events:
Konstrukt::Plugin::usermanagement::basic::registered
Konstrukt::Plugin::usermanagement::basic::deregistered
Each with the user id as an argument. So your plugin might register for those events, if it wants to react on these events.
CONFIGURATION
You have to do some konstrukt.settings-configuration to let the plugin know where to get its data and which layout to use:
#backend
usermanagement/basic/backend DBI
See the documentation of the backend modules (e.g. "CONFIGURATION" in Konstrukt::Plugin::usermanagement::basic::DBI) for their configuration.
#layout
usermanagement/basic/template_path /templates/usermanagement/basic/
METHODS
init
Initializes this object. Sets $self->{backend} and $self->{template_path}.
init()
will be called the first time this plugin is needed each request.
install
Installs the templates.
Parameters:
none
execute_again
Yes, this plugin may return dynamic nodes (i.e. template nodes).
prepare
Prepare method
Parameters:
$tag - Reference to the tag (and its children) that shall be handled.
execute
Execute method
Parameters:
$tag - Reference to the tag (and its children) that shall be handled.
register_show
Displays the register form.
register
Takes the HTTP form input and tries to register a new user. The user will be added to the database and an email will be sent to the users email address.
Returns a confirmation of the successful registration or error messages otherwise
deregister_show
Displays the deregister form.
deregister
Takes the HTTP form input and tries to deregister an existing user. The user will be removed from the database.
Returns a confirmation of the successful deregistration or error messages otherwise
login_show
Displays the login form.
login
Takes the HTTP form input and tries to login the user. The user id will be saved inside the session.
Returns a confirmation of the successful login or error messages otherwise.
Parameters:
$email - Optional: Username
$pass - Optional: Password
logout_show
Displays the logout form.
logout
Logs out the current user. The user id will be removed from the session.
sendpass_show
Displays the "send password" form.
sendpass
Generates a new password for the user and sends an email with the password to the user. The email address may be passed as a parameter to this sub. If not passed, it will be received from the HTTP parametes.
Returns a confirmation of the successfully sent email or error messages otherwise.
Parameters:
$email - Optional: The email address of the user to whom the pass should be sent
changepass_show
Displays the "change password" form.
changepass
Changes the password of the user that is currently logged in. The old password will be checked and the new ones must be identical. The parameters are optional. They will be received from HTTP parameters, if not specified.
Returns a confirmation of the successful password change or error messages otherwise.
Parameters (optional):
$old_pass - The old password.
$new_pass - The new password.
$new_pass2 - The new password (confirmation).
id
Returns the user id of the user, which is currently logged in, 0 if not logged in.
Returns the user's email address, if uid exists, undef otherwise.
data
Returns all relevant user data as an anonymous hash, if uid exists:
{ email => 'a@b.c', pass => '<hash>' }
Returns an empty hash if the uid doesn't exist.
Parameters (optional):
$uid - The user id (optional)
AUTHOR
Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.
This document is free software. It is distributed under the same terms as Perl itself.
SEE ALSO
Konstrukt::Plugin::usermanagement::basic::DBI, Konstrukt::Plugin, Konstrukt