Skip to content

Instantly share code, notes, and snippets.

@perigrin
Created August 10, 2009 17:31
Show Gist options
  • Select an option

  • Save perigrin/165295 to your computer and use it in GitHub Desktop.

Select an option

Save perigrin/165295 to your computer and use it in GitHub Desktop.

Inside Web.PM

use Catalyst qw(
…
Authentication
…
)


__PACKAGE__->config(
    name                     => 'MyApp::Web',
    'Plugin::ConfigLoader'   => { file => 'conf/catalyst.yml' },
    'Plugin::Authentication' => {
        default_realm => 'user',
        use_session   => 1,
        user          => {
            credential => {
                class         => 'Password',
                password_type => 'self_check'
            },
            store => {
                class      => 'Model::KiokuDB',
                model_name => 'Kioku',
            }
        }
    },

);

Inside your Model::API

sub find_user {
    my ( $self, $userinfo ) = @_;
    my $u = $self->directory->lookup( $userinfo->{id} );
    return $u;
}

and inside your User object:

package MyApp::Model::User;
use Moose;

use KiokuDB::Util qw(set weak_set);
use MooseX::Aliases;
use namespace::autoclean;

with qw(
  KiokuX::User
);

has id => (
    isa      => 'Str',
    is       => 'ro',
    alias    => ['key' ],
    init_arg => 'phone',
    required => 1,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment