Konstrukt::Plugin::usermanagement::basic - Basic user management.
<!-- 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" / &>
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 #...
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.
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.
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/
Initializes this object. Sets $self->{backend} and $self->{template_path}.
init() will be called the first time this plugin is needed each request.
init()
Installs the templates.
Parameters:
none
Yes, this plugin may return dynamic nodes (i.e. template nodes).
Prepare method
$tag - Reference to the tag (and its children) that shall be handled.
Execute method
Displays the register form.
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
Displays the deregister form.
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
Displays the login form.
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.
$email - Optional: Username
$pass - Optional: Password
Displays the logout form.
Logs out the current user. The user id will be removed from the session.
Displays the "send password" form.
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.
$email - Optional: The email address of the user to whom the pass should be sent
Displays the "change password" form.
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).
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.
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.
$uid - The user id (optional)
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.
Konstrukt::Plugin::usermanagement::basic::DBI, Konstrukt::Plugin, Konstrukt
To install Konstrukt, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Konstrukt
CPAN shell
perl -MCPAN -e shell install Konstrukt
For more information on module installation, please visit the detailed CPAN module installation guide.