Setup to use OpenID as well as local auth..
requires 'Catalyst::Plugin::Session';
requires 'Catalyst::Plugin::Session::Store::File';
requires 'Catalyst::Plugin::Session::State::Cookie';
-requires 'CatalystX::SimpleLogin';
+requires 'CatalystX::Controller::Auth';
##
requires 'Moose';
requires 'TryCatch';
ConfigLoader
Static::Simple
Unicode::Encoding
- +CatalystX::SimpleLogin
Authentication
Session
Session::Store::File
Session::State::Cookie
+ StatusMessage
/;
extends 'Catalyst';
class => 'Model::KiokuDB',
model_name => 'User',
},
- }
+ },
+ openid => {
+ credential => {
+ class => 'OpenID',
+ },
+ store => {
+ class => 'Model::KiokuDB',
+ model_name => 'User',
+ },
+ auto_create_user => 1,
+ },
+ },
+ ## Auth with CatalystX::Controller::Auth
+ 'Controller::Users' => {
+ model => 'User',
+ login_id_field => 'username',
+ login_db_field => 'username',
+ action_after_login => '/index',
+ send_register_email => 0,
+ realm => 'openid',
+ login_fields => { openid => [], # qw/openid_identifier/],
+ default => [qw/username password/],
+ },
},
);
--- /dev/null
+package stemmaweb::Controller::Users;
+use Moose;
+use namespace::autoclean;
+
+BEGIN {extends 'CatalystX::Controller::Auth'; }
+
+=head1 NAME
+
+stemmaweb::Controller::Users - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+sub base :Chained('/') :PathPart('') :CaptureArgs(0)
+{
+ my ( $self, $c ) = @_;
+
+ $self->next::method( $c );
+}
+
+=head2 index
+
+=cut
+
+sub index :Path :Args(0) {
+ my ( $self, $c ) = @_;
+
+ $c->response->body('Matched stemmaweb::Controller::Users in Users.');
+}
+
+
+=head1 AUTHOR
+
+A clever guy
+
+=head1 LICENSE
+
+This library is free software. You can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+
+1;
has '+model_class' => ( default => 'Text::Tradition::UserStore' );
+1;
+
=head1 NAME
stemmaweb::Model::User - User/Auth KiokuDB model for stemmaweb
To replace the source of users for authentication, add the
configuration shown in the L</SYNOPSIS> to your stemmaweb.conf file,
and adjust as necessary.
-
-1;
--- /dev/null
+[% IF status_msg %]
+ <p>[% status_msg | html %]</p>
+[% END %]
+[% IF error_msg %]
+ <p class="error">[% error_msg | html %]</p>
+[% END %]
+
+[% IF form.has_errors %]
+ <p class="error">Some fields had errors:</p>
+
+ <ul class="errors">
+ [% FOREACH msg IN form.errors %]
+ <li>[% msg | html %]</li>
+ [% END %]
+ </ul>
+[% END %]
+
+ <form method="post" action="[% c.uri_for_action('/users/login').hostless | html %]" autocomplete="off">
+
+ <select name="realm">
+ <option value="default">Local</option>
+ <option value="openid">OpenID</option>
+ </select>
+
+<div id="field-openid-identifier">
+<label for="openid_identifier">OpenID login/url</label>
+<input type="text" name="openid_identifier" id="openid_identifier"/><br>
+</div>
+
+<!--
+<div style="display:none">
+ [% form.field('username').render %]
+ [% form.field('password').render %]
+</div>
+-->
+ [% form.field('remember').render %]
+ [% form.field('submit').render %]
+
+ </form>
\ No newline at end of file
--- /dev/null
+[% IF status_msg %]
+ <p>[% status_msg | html %]</p>
+[% END %]
+[% IF error_msg %]
+ <p class="error">[% error_msg | html %]</p>
+[% END %]
+
+[% IF form.has_errors %]
+ <p class="error">Some fields had errors:</p>
+
+ <ul class="errors">
+ [% FOREACH msg IN form.errors %]
+ <li>[% msg | html %]</li>
+ [% END %]
+ </ul>
+[% END %]
+
+ <form method="post" action="[% c.uri_for_action('/users/register').hostless | html %]" autocomplete="off">
+
+ [% form.field('username').render %]
+ [% form.field('password').render %]
+ [% form.field('confirm_password').render %]
+
+ [% form.field('submit').render %]
+
+ </form>
\ No newline at end of file
--- /dev/null
+use strict;
+use warnings;
+use Test::More;
+
+
+use Catalyst::Test 'stemmaweb';
+use stemmaweb::Controller::Users;
+
+ok( request('/users')->is_success, 'Request should succeed' );
+done_testing();