du brauchst ein schema:
package PBoard::Schema::DBIC;
use base qw/DBIx::Class::Schema/;
use DateTime::Format::Pg ();
__PACKAGE__->load_classes(
qw[
PbBoardBoards PbBoardMessages PbBoardSettings PbBoardThreads
PbRole
PbUser PbUserProfile PbUserRole PbUserSession PbUserSettings
]
);
1;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package PBoard::Schema::DBIC::PbUser;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw[ PK::Auto Core ]);
__PACKAGE__->table('pboard.pb_user');
__PACKAGE__->add_columns(qw[ user_id username password old_user_id ]);
__PACKAGE__->set_primary_key(qw[ user_id ]);
__PACKAGE__->has_many( roles => 'PBoard::Schema::DBIC::PbUserRole', 'user_id' );
__PACKAGE__->has_one(
profile => 'PBoard::Schema::DBIC::PbUserProfile',
'user_id'
);
__PACKAGE__->has_one(
settings => 'PBoard::Schema::DBIC::PbUserSettings',
'user_id'
);
use Crypt::SaltedHash ();
use Digest::MD5 ();
sub check_password {
my ( $self, $password ) = @_;
if ( $password =~ m[^{.*}] ) { # like {SHA256}
my $salt_len =
$self->can("password_salt_len") ? $self->password_salt_len : 0;
return Crypt::SaltedHash->validate( $self->password, $password,
$salt_len );
}
else {
# old board method
my $passdword_digest =
&Digest::MD5::md5_hex( $password . lc( $self->username ) );
return $self->password eq $passdword_digest;
}
}
sub get_group {
my ( $self ) = @_;
my $roles = $self->roles;
}
1;
und dann nur noch ein Model
package PBoard::Model::DBIC;
use strict;
use base 'Catalyst::Model::DBIC::Schema';
__PACKAGE__->config(
schema_class => 'PBoard::Schema::DBIC',
connect_info => [
'dbi:Pg:dbname=pboard',
'pboard',
'pboard',
{RaiseError => 1, PrintError => 0, AutoCommit => 1},
],
);
1;