NAME

Dancer::Plugin::Authorize::Credentials - Dancer::Plugin::Authorize Credentials base class and guide!

VERSION

version 0.01

SYNOPSIS

package Dancer::Plugin::Authorize::Credentials::MyAuthorizationClass;
use base 'Dancer::Plugin::Authorize::Credentials';

sub authorize {
    my ($self, $options, @arguments) = @_;
    my ($login, $password) = @arguments;
    my $settings = $class::settings;
    
    if ($login && $password) {
        
        # try to perform login
        if ($passed) {
            
            my $session_data = {
                id    => '...',
                name  => '...',
                login => '...',
                roles => [qw/ ... /],
                error => []
            };
            return $self->credentials($session_data);
            
        }
        
    }
    else {
        
        # try session checking
        my $user = $self->credentials;
        if ($user) {
            ...
        }
        else {
            $self->errors(@errors);
        }
        
    }
    
}

1;

DESCRIPTION

The Dancer::Plugin::Authorize::Credentials class should be used as a base class in your custom credentials/authorization classes. When used as a base class, this class provides instantiation and simple error handling for your authorization classes.

AUTHOR

Al Newkirk <awncorp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by awncorp.

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