X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fstemmaweb%2FController%2FUsers.pm;h=96516a7a1239b66e73209e5c4f9405efb21a7ad1;hb=32d1fbf8a53b71b4e981c1b9e7aa6e966b872394;hp=32f629fcd8c0f87df411ca57cc044b0c64b3c97c;hpb=eb38afbcd0ef1e20b95b9954a0b8d0f107d0c342;p=scpubgit%2Fstemmaweb.git diff --git a/lib/stemmaweb/Controller/Users.pm b/lib/stemmaweb/Controller/Users.pm index 32f629f..96516a7 100644 --- a/lib/stemmaweb/Controller/Users.pm +++ b/lib/stemmaweb/Controller/Users.pm @@ -2,6 +2,13 @@ package stemmaweb::Controller::Users; use Moose; use namespace::autoclean; +use Google::JWT; + +use JSON::MaybeXS; +use JSON::WebToken; + +use MIME::Base64; + BEGIN {extends 'CatalystX::Controller::Auth'; } with 'Catalyst::TraitFor::Controller::reCAPTCHA'; @@ -56,6 +63,12 @@ before login => sub { my($self, $c) = @_; $c->req->param( realm => 'openid') if $c->req->param('openid-check'); + + if ($c->req->params->{email} && $c->req->params->{id_token}) { + $c->req->param( realm => 'google'); + } + + $c->stash->{google_client_id} = $c->config->{'Authentication::Credential::Google'}->{client_id}; }; =head2 register with recaptcha @@ -70,13 +83,16 @@ form with an error message. before register => sub { my ($self, $c) = @_; + warn $c->config->{'Registration'}->{'no_recaptcha'}; + ## Puts HTML into stash in "recaptcha" key. - $c->forward('captcha_get'); + if (!$c->config->{'Registration'}->{'no_recaptcha'}) { + $c->forward('captcha_get'); + } ## When submitting, check recaptcha passes, else re-draw form if($c->req->method eq 'POST') { - if(!$c->forward('captcha_check')) { - + if ( !$c->config->{'Registration'}->{'no_recaptcha'} && !$c->forward('captcha_check') ) { ## Need these two lines to detach, so end can draw the correct template again: my $form = $self->form_handler->new( active => [ $self->login_id_field, 'password', 'confirm_password' ] ); $c->stash( template => $self->register_template, form => $form );