The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Amon2::Auth::Site::Loctouch - Loctouch integration for Amon2

SYNOPSIS

    __PACKAGE__->load_plugin('Web::Auth', {
        module => 'Loctouch',
        on_finished => sub {
            my ($c, $token, $user) = @_;
            my $name = $user->{name} || die;
            $c->session->set('name' => $name);
            $c->session->set('site' => 'loctouch');
            return $c->redirect('/');
        }
    });

DESCRIPTION

This is a loctouch authentication module for Amon2. You can call a loctouch APIs with this module.

ATTRIBUTES

client_id
client_secret
redirect_uri(Required)
user_info(Default: true)

Fetch user information after authenticate?

ua(instance of LWP::UserAgent)

You can replace instance of LWP::UserAgent.

METHODS

$auth->auth_uri($c:Amon2::Web, $callback_uri : Str) :Str

Get a authenticate URI.

$auth->callback($c:Amon2::Web, $callback:HashRef) : Plack::Response

Process the authentication callback dispatching.

$callback MUST have two keys.

on_error

on_error callback function is called if an error was occurred.

The arguments are following:

    sub {
        my ($c, $error_message) = @_;
        ...
    }
on_finished

on_finished callback function is called if an authentication was finished.

The arguments are following:

    sub {
        my ($c, $access_token, $user) = @_;
        ...
    }

$user contains user information. This code contains a information like https://api.loctouch.com/users/dankogai.

If you set $auth->user_info as false value, authentication engine does not pass $user.