From: Tara L Andrews Date: Thu, 12 Jul 2012 21:07:42 +0000 (+0200) Subject: integrate login/register functionality more properly with app X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eb38afbcd0ef1e20b95b9954a0b8d0f107d0c342;p=scpubgit%2Fstemmaweb.git integrate login/register functionality more properly with app --- diff --git a/Makefile.PL b/Makefile.PL index 7c833af..40572d0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -24,7 +24,7 @@ requires 'Catalyst::Plugin::Authentication'; requires 'Catalyst::Plugin::Session'; requires 'Catalyst::Plugin::Session::Store::File'; requires 'Catalyst::Plugin::Session::State::Cookie'; -requires 'CatalystX::Controller::Auth'; +requires 'CatalystX::Controller::Auth' => '0.22'; requires 'Catalyst::TraitFor::Controller::reCAPTCHA'; requires 'LWP::Protocol::https'; ## diff --git a/lib/stemmaweb.pm b/lib/stemmaweb.pm index 4563222..ba6ea4a 100644 --- a/lib/stemmaweb.pm +++ b/lib/stemmaweb.pm @@ -99,9 +99,9 @@ __PACKAGE__->config( model => 'User', login_id_field => 'username', login_db_field => 'username', - action_after_login => '/index', - action_after_register => '/index', - register_email_from => '"MyApp" ', + action_after_login => '/users/success', + action_after_register => '/users/success', + register_email_from => '"Stemmaweb" ', register_email_subject => 'Registration to stemmaweb', register_email_template_plain => 'register-plain.tt', realm => 'default', @@ -114,8 +114,8 @@ __PACKAGE__->config( }, recaptcha => { - pub_key => '', - priv_key => '', + pub_key => '6LfR19MSAAAAACy2meHvLfZGRn3PM2rRYIAfh665', + priv_key => '6LfR19MSAAAAAMlQb8BdyecWNRE1bAL2YSgz2sah', }, ); diff --git a/lib/stemmaweb/Controller/Users.pm b/lib/stemmaweb/Controller/Users.pm index 8a5c6ac..32f629f 100644 --- a/lib/stemmaweb/Controller/Users.pm +++ b/lib/stemmaweb/Controller/Users.pm @@ -47,7 +47,7 @@ sub index :Path :Args(0) { Logging in with openid/google requires two passes through the login action, on the 2nd pass the C value is passed in when the openid providing webserver links the user back to the stemmaweb -site. This adaption to the C action sets the realm we are +site. This adaptation to the C action sets the realm we are authenticating against to be C in this case. =cut @@ -86,6 +86,31 @@ before register => sub { } }; +=head2 success + +A stub page returned on login / registration success. + +=cut + +sub success :Local :Args(0) { + my ( $self, $c ) = @_; + + $c->load_status_msgs; + $c->stash->{template} = 'auth/success.tt'; +} + +=head2 post_logout + +Return to the index page, not to the login page. + +=cut + +sub post_logout { + my( $self, $c ) = @_; + $c->response->redirect( $c->uri_for_action( '/index' ) ); + $c->detach; +} + =head1 AUTHOR A clever guy diff --git a/root/css/auth.css b/root/css/auth.css new file mode 100644 index 0000000..0717b5f --- /dev/null +++ b/root/css/auth.css @@ -0,0 +1,8 @@ +#topbanner { + width: 100%; + height: 50px; + margin-top: 20px; +} +.error { + color: #d24848; +} diff --git a/root/css/style.css b/root/css/style.css index a3047f9..4aaa2b9 100644 --- a/root/css/style.css +++ b/root/css/style.css @@ -58,6 +58,22 @@ div.button:hover span { background-position: bottom left; } +#topbanner { + width: 100%; + height: 100px; + margin-top: 20px; +} +#bannerinfo { + float: right; + margin-right: 12%; + margin-top: 15px; +} +.navlink { + color: #488dd2; + text-decoration: underline; +} + + /* Index page components */ diff --git a/root/src/auth/login.tt b/root/src/auth/login.tt index 7779789..61575b1 100644 --- a/root/src/auth/login.tt +++ b/root/src/auth/login.tt @@ -1,3 +1,30 @@ +[% WRAPPER header.tt + pagetitle = "Stemmaweb - Sign in" + applicationstyle = c.uri_for('/css/auth.css') +%] + +[% END %] +
+

Stemmaweb - Sign in

+
+ +
[% IF status_msg %]

[% status_msg | html %]

[% END %] @@ -14,25 +41,47 @@ [% END %] [% END %] +
+[% UNLESS status_msg == 'Logged in!' %] +
+

Sign in with Google

+
+

If you have a Google account, you may use it to sign into Stemmaweb.

+
+ + + +
+
-
- - - - - -
+

Sign in with OpenID

+
+

If you have an account with an OpenID provider (e.g. WordPress, Blogger, Flickr, Yahoo), you may use it to sign into Stemmaweb. +

+ + + +
+
[% UNLESS c.req.param('realm') == 'openid' %] -
- - - - [% form.field('username').render %] - [% form.field('password').render %] - [% form.field('remember').render %] - - [% form.field('submit').render %] - -
-[% END %] \ No newline at end of file +

Sign in with Stemmaweb

+
+

If you do not have Google or another OpenID account, you may register for a user account here with its own password. Once you are registered, you can use this form to sign in.

+
+ + [% userlabel = form.field('username').label('Email address') %] + [% form.field('username').render %] + [% form.field('password').render %] + + [% rememberlabel = form.field('remember').label('Remember me') %] + [% form.field('remember').render %] + + [% submitbutton = form.field('submit').value('Sign in with Stemmaweb') %] + [% form.field('submit').render %] +
+
+[% END %] +
+[% END %] +[% PROCESS footer.tt %] \ No newline at end of file diff --git a/root/src/auth/register.tt b/root/src/auth/register.tt index 2f91791..97384be 100644 --- a/root/src/auth/register.tt +++ b/root/src/auth/register.tt @@ -1,3 +1,7 @@ +[% PROCESS header.tt + pagetitle = "Stemmaweb - Register" + applicationstyle = c.uri_for('/css/auth.css') +%] [% IF status_msg %]

[% status_msg | html %]

[% END %] @@ -15,9 +19,10 @@ [% END %] -
+ - [% form.field('username').render %] (email) + [% userlabel = form.field('username').label('Email address') %] + [% form.field('username').render %] [% form.field('password').render %] [% form.field('confirm_password').render %] @@ -28,4 +33,5 @@ [% form.field('submit').render %] -
\ No newline at end of file + +[% PROCESS footer.tt %] \ No newline at end of file diff --git a/root/src/auth/success.tt b/root/src/auth/success.tt new file mode 100644 index 0000000..39189cf --- /dev/null +++ b/root/src/auth/success.tt @@ -0,0 +1,29 @@ +[% WRAPPER header.tt + pagetitle = "Stemmaweb - Logged in" + applicationstyle = c.uri_for('/css/auth.css') +%] + +[% END %] +
+

Stemmaweb - Signed in

+
+ +
+[% IF status_msg %] +

[% status_msg | html %]

+

Please wait...

+[% END %] +
+[% PROCESS footer.tt %] \ No newline at end of file diff --git a/root/src/index.tt b/root/src/index.tt index 68cebc7..4131aeb 100644 --- a/root/src/index.tt +++ b/root/src/index.tt @@ -14,7 +14,7 @@ $(document).ready(function() {

Stemmaweb - a collection of tools for analysis of collated texts

- [% IF c.user_exists %]Hello! [% c.user.get_object.email %] [% ELSE %]Login | Register | [% END %]About | Help + [% IF c.user_exists %]Hello! [% c.user.get_object.email %] Sign out | [% ELSE %]Login | Register | [% END %]About

Text directory