Web::Authenticate::User::Storage::Handler::SQL - Implementation of Web::Authenticate::User::Storage::Handler::Role that can be used with MySQL or SQLite.
version 0.013
This Web::Authenticate::User::Storage::Handler::Role is meant to be used with a very specific table structure:
CREATE TABLE users ( id INTEGER PRIMARY KEY AUTO_INCREMENT, username VARCHAR(255) NOT NULL UNIQUE, password TEXT NOT NULL );
Other columns can exists, and the names of the table and column can change. But at least these columns must exist in order for this storage handler to work properly. Also, the primary key does not have to be an integer, and could even be the username.
Sets the name of the users table that will be used when querying the database. Default is 'users'.
Sets the name of the id field that will be used when querying the database. Default is 'id'.
Sets the name of the username field that will be used when querying the database. Default is 'username'.
Sets the name of the password field that will be used when querying the database. Default is 'password'.
Sets the Web::Authenticate::Digest::Role that is used. Default is Web::Authenticate::Digest.
Sets the DBIx::Raw object that will be used to query the database. This is required with no default.
The columns to select. At a minimum, "id_field" and "password_field" will always be selected.
$user_storage_handler->columns([qw/name age/]);
Default is an empty array ref.
Accepts the username and password for a user, and returns a Web::Authenticate::User if the password is correct and the user exists. Otherwise, undef is returned. Any additional "columns" will be stored in "row" in Web::Authenticate::User. However, the password will be deleted from the row before it is stored.
my $user = $user_storage_handler->load_user($username, $password);
Loads a user by id.
my $user = $user_storage_handler->load_user_by_id($user_id);
Takes in username, password, and any additional values for columns in a hash and we create that user with their hashed password. Returns a Web::Authenticate::User with any values from "columns" stored in "row" in Web::Authenticate::User.
my $user_values => { name => 'Fred', age => 34, insert_time => \'NOW()', # scalar ref for literal values. See DBIx::Raw }; my $user = $user_storage_handler->store_user($username, $password, $user_vaules); # if you need no extra user values in the row my $user = $user_storage_handler->store_user($username, $password);
Adam Hopkins <srchulo@cpan.org>
This software is copyright (c) 2017 by Adam Hopkins.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Web::Authenticate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Web::Authenticate
CPAN shell
perl -MCPAN -e shell install Web::Authenticate
For more information on module installation, please visit the detailed CPAN module installation guide.