use Moose;
use KiokuX::User::Util qw(crypt_password);
+extends 'KiokuX::Model';
+
use Text::Tradition::User;
-use Text::Tradition::Directory;
-has 'directory' => ( is => 'rw', isa => 'KiokuX::Model');
+# has 'directory' => (
+# is => 'rw',
+# isa => 'KiokuX::Model',
+# handles => []
+# );
sub add_user {
my ($self, $username, $password) = @_;
password => crypt_password($password),
);
- my $scope = $self->directory->new_scope;
- $self->directory->store($user->kiokudb_object_id, $user);
+ my $scope = $self->new_scope;
+ $self->store($user->kiokudb_object_id, $user);
return $user;
}
sub find_user {
- my ($self, $username) = @_;
+ my ($self, $userinfo) = @_;
+ my $username = $userinfo->{username};
- return $self->directory->lookup($self->user_prefix . $username);
+ return $self->lookup(Text::Tradition::User->id_for_user($username));
}
requires 'Catalyst::View::Download::Plain';
requires 'Catalyst::View::JSON';
requires 'Catalyst::View::TT';
+## Auth:
+requires 'Catalyst::Plugin::Authentication';
+requires 'Catalyst::Plugin::Session';
+requires 'Catalyst::Plugin::Session::Store::File';
+requires 'Catalyst::Plugin::Session::State::Cookie';
+requires 'CatalystX::SimpleLogin';
+##
requires 'Moose';
requires 'TryCatch';
requires 'namespace::autoclean';
use Catalyst::Runtime 5.80;
+use Search::GIN::Extract::Class;
+use Search::GIN::Extract::Attributes;
+use Search::GIN::Extract::Multiplex;
+
# Set flags and add plugins for the application.
#
# Note that ORDERING IS IMPORTANT here as plugins are initialized in order,
ConfigLoader
Static::Simple
Unicode::Encoding
+ +CatalystX::SimpleLogin
+ Authentication
+ Session
+ Session::Store::File
+ Session::State::Cookie
/;
extends 'Catalyst';
stemmaweb->path_to( 'root', 'src' ),
],
},
+ ## kiokudb auth store testing
+ 'Plugin::Authentication' => {
+ default => {
+ credential => {
+ class => 'Password',
+ password_field => 'password',
+ password_type => 'self_check',
+ },
+ store => {
+ class => 'Model::KiokuDB',
+ model_name => 'User',
+ },
+ }
+ },
);
# Start the application
--- /dev/null
+package stemmaweb::Model::User;
+use strict;
+use warnings;
+use Moose;
+use Text::Tradition::UserStore;
+
+extends 'Catalyst::Model::KiokuDB';
+
+has '+model_class' => ( default => 'Text::Tradition::UserStore' );
+
+1;
name = stemmaweb
<Model Directory>
dsn dbi:SQLite:dbname=db/traditions.db
-</Model>
\ No newline at end of file
+</Model>
+<Model User>
+ dsn dbi:SQLite:dbname=db/traditions.db
+</Model>
use warnings;
use Test::More 'no_plan';
-use KiokuX::Model;
+# use KiokuX::Model;
use File::Temp;
use_ok('Text::Tradition::UserStore');
my $file = $fh->filename;
$fh->close;
my $dsn = "dbi:SQLite:dbname=$file";
-my $d = KiokuX::Model->new( 'dsn' => $dsn,'extra_args' => { 'create' => 1 } );
+# my $d = KiokuX::Model->new( 'dsn' => $dsn,'extra_args' => { 'create' => 1 } );
-my $user_store = Text::Tradition::UserStore->new(directory => $d);
+my $user_store = Text::Tradition::UserStore->new('dsn' => $dsn,'extra_args' => { 'create' => 1 } );
+## create user
my $new_user = $user_store->add_user('fred', 'bloggs');
isa_ok($new_user, 'Text::Tradition::User');
+## find user
+my $find_user = $user_store->find_user({ username => 'fred'});
+isa_ok($find_user, 'Text::Tradition::User');
+ok($find_user->check_password('bloggs'), 'Stored & retrieved with correct password');
+
+
+