我正在尝试使用DBIx::Class
从Catalyst应用程序进行身份验证用户。 我的步骤我做:无法使用DBIx :: Class从Catalyst应用程序进行身份验证
1)创建的SQLite数据库
CREATE TABLE people (
id integer primary key,
name text not null,
password text not null);
2)建立催化剂型号的人;
3)设置在MyApp.pm
__PACKAGE__->config('Plugin::Authentication' => {
default => { credential => {
class => 'Password',
password_field => 'password',
password_type => 'clear'
},
store => {
class => 'DBIx::Class',
user_model => 'People'
}
}
}
);
4)创建控制器验证AUTH配置和设置方法的登录在它:
sub login : Local {
my ($self, $c) = @_;
if (my $user = $c->req->params->{user} and my $password = $c->req->params->{password}) {
if ($c->authenticate({ username => $user, password => $password })) {
$c->res->body("hello " . $c->user->get("id"));
} else {
# login incorrect
$c->res->body("Wrong pass or name!");
}
} else {
# invalid form input
$c->res->body("Type name & pass");
}
}
5)调用的方法的登录时与用户的形式组织并提交密码数据。在MyApp的
捕捉到异常::控制器:: Auth->登录“无法找到 对象的方法‘result_source’通过一揽子‘MyApp的::型号::人’在 /:我得到这个消息usr/local/share/perl/5.14.2/Catalyst/Authentication/Store/DBIx/Class/User.pm line 35,line 999.“
如何解决?
“'store => {class =>'DBIx :: Class',user_model =>'MyApp :: Users',role_column =>'roles',}}});' 身份验证系统在幕后工作从新源加载数据,其余应用程序完全不变。“这是来自Catalyst :: Plugin :: Authentication的人。 – edem