1 package stemmaweb::Controller::Users;
3 use namespace::autoclean;
12 BEGIN {extends 'CatalystX::Controller::Auth'; }
13 with 'Catalyst::TraitFor::Controller::reCAPTCHA';
17 stemmaweb::Controller::Users - Catalyst Controller
21 The Users controller is based on L<CatalystX::Controller::Auth>, see
22 there for most of the functionality. Any localised parts are described
25 This controller uses L<Catalyst::TraitFor::Controller::reCAPTCHA> to
26 create and check a reCaptcha form shown on the C<register> form to
27 help prevent spam signups.
33 sub base :Chained('/') :PathPart('') :CaptureArgs(0)
35 my ( $self, $c ) = @_;
37 $self->next::method( $c );
42 The index action is not currently used.
46 sub index :Path :Args(0) {
47 my ( $self, $c ) = @_;
49 $c->response->body('Matched stemmaweb::Controller::Users in Users.');
52 =head2 login with openid
54 Logging in with openid/google requires two passes through the login
55 action, on the 2nd pass the C<openid-check> value is passed in when
56 the openid providing webserver links the user back to the stemmaweb
57 site. This adaptation to the C<login> action sets the realm we are
58 authenticating against to be C<openid> in this case.
64 $c->req->param( realm => 'openid')
65 if $c->req->param('openid-check');
67 if ($c->req->params->{email} && $c->req->params->{id_token}) {
68 $c->req->param( realm => 'google');
72 =head2 register with recaptcha
74 This adapts the C<register> action to add the recaptcha HTML to the
75 page, and verify the recaptcha info entered is correct when the form
76 is submitted. If the recaptcha is not correct, we just redisplay the
77 form with an error message.
81 before register => sub {
84 ## Puts HTML into stash in "recaptcha" key.
85 $c->forward('captcha_get');
87 ## When submitting, check recaptcha passes, else re-draw form
88 if($c->req->method eq 'POST') {
89 if(!$c->forward('captcha_check') || 0 ) {
90 ## Need these two lines to detach, so end can draw the correct template again:
91 my $form = $self->form_handler->new( active => [ $self->login_id_field, 'password', 'confirm_password' ] );
92 $c->stash( template => $self->register_template, form => $form );
101 A stub page returned on login / registration success.
105 sub success :Local :Args(0) {
106 my ( $self, $c ) = @_;
108 $c->load_status_msgs;
109 $c->stash->{template} = 'auth/success.tt';
114 Return to the index page, not to the login page.
119 my( $self, $c ) = @_;
120 $c->response->redirect( $c->uri_for_action( '/index' ) );
130 This library is free software. You can redistribute it and/or modify
131 it under the same terms as Perl itself.
135 __PACKAGE__->meta->make_immutable;