1 package stemmaweb::Controller::Users;
3 use namespace::autoclean;
5 BEGIN {extends 'CatalystX::Controller::Auth'; }
6 with 'Catalyst::TraitFor::Controller::reCAPTCHA';
10 stemmaweb::Controller::Users - Catalyst Controller
14 The Users controller is based on L<CatalystX::Controller::Auth>, see
15 there for most of the functionality. Any localised parts are described
18 This controller uses L<Catalyst::TraitFor::Controller::reCAPTCHA> to
19 create and check a reCaptcha form shown on the C<register> form to
20 help prevent spam signups.
26 sub base :Chained('/') :PathPart('') :CaptureArgs(0)
28 my ( $self, $c ) = @_;
30 $self->next::method( $c );
35 The index action is not currently used.
39 sub index :Path :Args(0) {
40 my ( $self, $c ) = @_;
42 $c->response->body('Matched stemmaweb::Controller::Users in Users.');
45 =head2 login with openid
47 Logging in with openid/google requires two passes through the login
48 action, on the 2nd pass the C<openid-check> value is passed in when
49 the openid providing webserver links the user back to the stemmaweb
50 site. This adaptation to the C<login> action sets the realm we are
51 authenticating against to be C<openid> in this case.
57 $c->req->param( realm => 'openid')
58 if $c->req->param('openid-check');
61 =head2 register with recaptcha
63 This adapts the C<register> action to add the recaptcha HTML to the
64 page, and verify the recaptcha info entered is correct when the form
65 is submitted. If the recaptcha is not correct, we just redisplay the
66 form with an error message.
70 before register => sub {
73 ## Puts HTML into stash in "recaptcha" key.
74 $c->forward('captcha_get');
76 ## When submitting, check recaptcha passes, else re-draw form
77 if($c->req->method eq 'POST') {
78 if(!$c->forward('captcha_check')) {
80 ## Need these two lines to detach, so end can draw the correct template again:
81 my $form = $self->form_handler->new( active => [ $self->login_id_field, 'password', 'confirm_password' ] );
82 $c->stash( template => $self->register_template, form => $form );
91 A stub page returned on login / registration success.
95 sub success :Local :Args(0) {
96 my ( $self, $c ) = @_;
99 $c->stash->{template} = 'auth/success.tt';
104 Return to the index page, not to the login page.
109 my( $self, $c ) = @_;
110 $c->response->redirect( $c->uri_for_action( '/index' ) );
120 This library is free software. You can redistribute it and/or modify
121 it under the same terms as Perl itself.
125 __PACKAGE__->meta->make_immutable;