diff options
-rw-r--r-- | TODO.txt | 6 | ||||
-rw-r--r-- | perllib/CrossSell.pm | 32 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Auth.pm | 64 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 8 | ||||
-rw-r--r-- | t/app/controller/admin.t | 24 | ||||
-rw-r--r-- | t/app/controller/auth.t | 9 | ||||
-rw-r--r-- | templates/email/default/login.txt | 12 | ||||
-rw-r--r-- | templates/web/default/admin/council_contacts.html | 4 | ||||
-rw-r--r-- | templates/web/default/admin/council_edit.html | 2 | ||||
-rw-r--r-- | templates/web/default/auth/change_password.html | 26 | ||||
-rw-r--r-- | templates/web/default/auth/general.html | 39 | ||||
-rw-r--r-- | templates/web/default/auth/logout.html | 8 | ||||
-rw-r--r-- | templates/web/default/auth/token.html | 6 | ||||
-rw-r--r-- | templates/web/default/email_sent.html | 4 |
15 files changed, 132 insertions, 120 deletions
@@ -1,8 +1,4 @@ -Add users to system: - * script to migrate database - * best phone for users from problems - Auth: * add 'remember me' option on login. * limit session to this browser session on create account @@ -28,4 +24,4 @@ Framework: Future ideas: * dashboard for council to put on big screen -
\ No newline at end of file + diff --git a/perllib/CrossSell.pm b/perllib/CrossSell.pm index 44f971462..46c34a43b 100644 --- a/perllib/CrossSell.pm +++ b/perllib/CrossSell.pm @@ -143,38 +143,6 @@ details. You can unsubscribe at any time.</p> EOF } -sub display_tms_form { - my (%input) = @_; - my %input_h = map { $_ => $input{$_} ? ent($input{$_}) : '' } qw(name email postcode mobile signed_email); - my $auth_signature = $input_h{signed_email}; - return <<EOF; -<h1 style="padding-top:0.5em">Coming Soon: TextMyStreet</h1> - -<p>Exclusive to FixMyStreet users: Sign up for a <strong>brand new</strong>, not-yet-launched -service which will make it easy to send short messages to other people on <strong>your -street</strong> and just round the corner.</p> - -<p>Use it to borrow a strimmer, discuss the weather or report a <strong>lost cat</strong>.</p> - -<form action="/tms-signup" method="post"> -<input type="hidden" name="signed_email" value="$auth_signature"> -<label for="name">Name:</label> -<input type="text" name="name" id="name" value="$input_h{name}" size="30"> -<br><label for="email">Email:</label> -<input type="text" name="email" id="email" value="$input_h{email}" size="30"> -<br><label for="postcode">Postcode:</label> -<input type="text" name="postcode" id="postcode" value="$input_h{postcode}" size="11"> -<br><label for="mobile">Mobile:</label> <input type="text" name="mobile" id="mobile" value="$input_h{mobile}" size="11"> - <input type="submit" class="submit" value="Sign up"> -</form> - -<p>mySociety respects your privacy, and we'll never sell or give away your private -details. Once we launch we'll send you some emails and perhaps some texts -explaining how it works, and it'll never cost you a penny unless we explicitly -say it will. You'll be able to <strong>unsubscribe</strong> at any time.</p> -EOF -} - # Not currently used, needs more explanation and testing; perhaps in future. sub display_gny_groups { my ($lon, $lat) = @_; diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 5c73af26a..abc454600 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -331,7 +331,7 @@ sub display_contacts : Private { if ( $c->req->param('text') && $c->req->param('text') == 1 ) { $c->stash->{template} = 'admin/council_contacts.txt'; - $c->res->content_encoding('text/plain'); + $c->res->content_type('text/plain; charset=utf-8'); return 1; } @@ -356,6 +356,12 @@ sub setup_council_details : Private { return 1; } +sub council_edit_all : Path('council_edit') { + my ( $self, $c, $area_id, @category ) = @_; + my $category = join( '/', @category ); + $c->go( 'council_edit', [ $area_id, $category ] ); +} + sub council_edit : Path('council_edit') : Args(2) { my ( $self, $c, $area_id, $category ) = @_; diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm index 7526c2c25..9ff415bf4 100644 --- a/perllib/FixMyStreet/App/Controller/Auth.pm +++ b/perllib/FixMyStreet/App/Controller/Auth.pm @@ -30,6 +30,9 @@ sub general : Path : Args(0) { my ( $self, $c ) = @_; my $req = $c->req; + $c->detach( 'redirect_on_signin', [ $req->param('r') ] ) + if $c->user && $req->param('r'); + # all done unless we have a form posted to us return unless $req->method eq 'POST'; @@ -64,8 +67,7 @@ sub login : Private { $c->set_session_cookie_expire(0) unless $remember_me; - $c->res->redirect( $c->uri_for('/my') ); - return; + $c->detach( 'redirect_on_signin', [ $c->req->param('r') ] ); } # could not authenticate - show an error @@ -104,14 +106,16 @@ sub email_login : Private { ->create( { scope => 'email_login', - data => { email => $good_email } + data => { + email => $good_email, + r => $c->req->param('r'), + } } ); - # log the user in, send them an email and redirect to the welcome page $c->stash->{token} = $token_obj->token; $c->send_email( 'login.txt', { to => $good_email } ); - $c->res->redirect( $c->uri_for('token') ); + $c->stash->{template} = 'auth/token.html'; } =head2 token @@ -121,16 +125,15 @@ Handle the 'email_login' tokens. Find the account for the email address =cut -sub token : Local { +sub token : Path('/M') : Args(1) { my ( $self, $c, $url_token ) = @_; - # check for a token - if none found then return - return unless $url_token; - # retrieve the token or return - my $token_obj = - $c->model('DB::Token') - ->find( { scope => 'email_login', token => $url_token, } ); + my $token_obj = $url_token + ? $c->model('DB::Token')->find( { + scope => 'email_login', token => $url_token + } ) + : undef; if ( !$token_obj ) { $c->stash->{token_not_found} = 1; @@ -142,6 +145,7 @@ sub token : Local { # get the email and scrap the token my $email = $token_obj->data->{email}; + my $redirect = $token_obj->data->{r}; $token_obj->delete; # find or create the user related to the token and delete the token @@ -149,7 +153,35 @@ sub token : Local { $c->authenticate( { email => $user->email }, 'no_password' ); # send the user to their page - $c->res->redirect( $c->uri_for('/my') ); + $c->detach( 'redirect_on_signin', [ $redirect ] ); +} + +=head2 redirect_on_signin + +Used after signing in to take the person back to where they were. + +=cut + + +sub redirect_on_signin : Private { + my ( $self, $c, $redirect ) = @_; + $redirect = 'my' unless $redirect; + $c->res->redirect( $c->uri_for( "/$redirect" ) ); +} + +=head2 redirect + +Used when trying to view a page that requires login when you're not. + +=cut + +sub redirect : Private { + my ( $self, $c ) = @_; + + my $uri = $c->uri_for( '/auth', { r => $c->req->path } ); + $c->res->redirect( $uri ); + $c->detach; + } =head2 change_password @@ -161,11 +193,7 @@ Let the user change their password. sub change_password : Local { my ( $self, $c ) = @_; - # FIXME - handle not being logged in more elegantly - unless ( $c->user ) { - $c->res->redirect( $c->uri_for('/auth') ); - $c->detach; - } + $c->detach( 'redirect' ) unless $c->user; # FIXME - CSRF check here # FIXME - minimum criteria for passwords (length, contain number, etc) diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index 1189fe901..79d5c5681 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -22,13 +22,7 @@ Catalyst Controller. sub my : Path : Args(0) { my ( $self, $c ) = @_; - - # FIXME - handle not being logged in more elegantly - unless ( $c->user ) { - $c->res->redirect( $c->uri_for('/auth') ); - $c->detach; - } - + $c->detach( '/auth/redirect' ) unless $c->user; } __PACKAGE__->meta->make_immutable; diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 74fb4ae33..60cbd6937 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -136,18 +136,17 @@ subtest 'check summary counts' => sub { $mech->get_ok('/admin/council_contacts/2650'); $mech->content_contains('Aberdeen City Council'); $mech->content_contains('AB15 8RN'); +$mech->content_contains('street.com/around'); subtest 'check contact creation' => sub { - my $contact = FixMyStreet::App->model('DB::Contact')->find( - { area_id => 2650, category => 'test category' } + my $contact = FixMyStreet::App->model('DB::Contact')->search( + { area_id => 2650, category => [ 'test category', 'test/category' ] } ); - - $contact->delete if $contact; + $contact->delete_all; my $history = FixMyStreet::App->model('DB::ContactsHistory')->search( - { area_id => 2650, category => 'test category' } + { area_id => 2650, category => [ 'test category', 'test/category' ] } ); - $history->delete_all; $mech->get_ok('/admin/council_contacts/2650'); @@ -161,6 +160,14 @@ subtest 'check contact creation' => sub { $mech->content_contains( 'test category' ); $mech->content_contains( '<td>test@example.com' ); $mech->content_contains( '<td>test note' ); + + $mech->submit_form_ok( { with_fields => { + category => 'test/category', + email => 'test@example.com', + note => 'test/note', + } } ); + $mech->get_ok('/admin/council_edit/2650/test/category'); + }; subtest 'check contact editing' => sub { @@ -194,6 +201,11 @@ subtest 'check contact updating' => sub { $mech->content_like(qr{test2\@example.com[^<]*</td>[^<]*<td><strong>Yes}s); }; +subtest 'check text output' => sub { + $mech->get_ok('/admin/council_contacts/2650?text=1'); + is $mech->content_type, 'text/plain'; + $mech->content_contains('test category'); +}; my $log_entries = FixMyStreet::App->model('DB::AdminLog')->search( { diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t index a44716a1e..79db69704 100644 --- a/t/app/controller/auth.t +++ b/t/app/controller/auth.t @@ -57,7 +57,6 @@ $mech->submit_form_ok( }, "create an account for '$test_email'" ); -is $mech->uri->path, '/auth/token', "redirected to welcome page"; # check that we are not logged in yet $mech->not_logged_in_ok; @@ -108,12 +107,14 @@ $mech->not_logged_in_ok; $mech->submit_form_ok( { form_name => 'general_auth', - fields => { email => "$test_email", }, + fields => { + email => "$test_email", + r => 'faq', # Just as a test + }, button => 'email_login', }, "email_login with '$test_email'" ); - is $mech->uri->path, '/auth/token', "redirected to token page"; # rest is as before so no need to test @@ -125,7 +126,9 @@ $mech->not_logged_in_ok; $mech->clear_emails_ok; my ($link) = $email->body =~ m{(http://\S+)}; $mech->get_ok($link); + is $mech->uri->path, '/faq', "redirected to the Help page"; + $mech->get_ok('/my'); $mech->follow_link_ok( { url => '/auth/change_password' } ); ok my $form = $mech->form_name('change_password'), diff --git a/templates/email/default/login.txt b/templates/email/default/login.txt index c873e82af..d24f1cc4f 100644 --- a/templates/email/default/login.txt +++ b/templates/email/default/login.txt @@ -1,12 +1,10 @@ Subject: [% loc('Your FixMyStreet.com account details') %] -Please click on the link below to confirm your email address. Then you will be able to view your problem reports. +Please click on the link below to confirm your email address. Then you will be +able to view your problem reports and manage them more easily. -[% c.uri_for( '/auth/token', token ) %] - -We will never give away or sell your email address to anyone else without your permission. - -Yours, - the FixMyStreet.com team +[% c.uri_for_action( 'auth/token', token ) %] +Yours, +The FixMyStreet.com team diff --git a/templates/web/default/admin/council_contacts.html b/templates/web/default/admin/council_contacts.html index e7cacf4f8..669f137f9 100644 --- a/templates/web/default/admin/council_contacts.html +++ b/templates/web/default/admin/council_contacts.html @@ -6,9 +6,9 @@ <p> [% IF example_pc %] -<a href="[% c.uri_for( '/around', { pc => example_pc } ) %]">[% tprintf( loc('Example postcode %s'), example_pc ) | html %]</a> | +<a href="[% c.uri_for_email( '/around', { pc => example_pc } ) %]">[% tprintf( loc('Example postcode %s'), example_pc ) | html %]</a> | [% END %] -<a href="[% c.uri_for( '/reports', { council => area_id } ) %]">[% loc('List all reported problems' ) %]</a> +<a href="[% c.uri_for_email( '/reports/' _ area_id ) %]">[% loc('List all reported problems' ) %]</a> <a href="[% c.uri_for( 'council_contacts', area_id, { text => 1 } ) %]">[% loc('Text only version') %]</a> </p> diff --git a/templates/web/default/admin/council_edit.html b/templates/web/default/admin/council_edit.html index f6e820bab..0968d3570 100644 --- a/templates/web/default/admin/council_edit.html +++ b/templates/web/default/admin/council_edit.html @@ -15,7 +15,7 @@ <p> [% IF example_pc %] -<a href="[% c.uri_for( '/around', { pc => example_pc } ) %]">[% tprintf( loc('Example postcode %s'), example_pc ) | html %]</a> +<a href="[% c.uri_for_email( '/around', { pc => example_pc } ) %]">[% tprintf( loc('Example postcode %s'), example_pc ) | html %]</a> [% END %] </p> diff --git a/templates/web/default/auth/change_password.html b/templates/web/default/auth/change_password.html index d4a7f107b..2dd37cb91 100644 --- a/templates/web/default/auth/change_password.html +++ b/templates/web/default/auth/change_password.html @@ -1,4 +1,4 @@ -[% INCLUDE 'header.html', title => loc('Change Password') %] +[% INCLUDE 'header.html', title = loc('Change Password') %] <h1>[% loc('Change Password') %]</h1> @@ -9,6 +9,8 @@ <form action="[% c.uri_for('change_password') %]" method="post" name="change_password"> + <div id="fieldset"> + [% IF password_error; errors = { @@ -17,23 +19,23 @@ other => loc('Please check the passwords and try again'), }; - loc_password_error = errors.$password_error || errors.other; - END %] - - - <div> - <span class="error">[% loc_password_error %]</span><br> + loc_password_error = errors.$password_error || errors.other; %] + <div class="form-error">[% loc_password_error %]</div> + [% END %] + + <div class="form-field"> <label for="new_password">[% loc('Password:') %]</label> <input type="password" name="new_password" value="[% new_password | html %]"> - <br> - + </div> + <div class="form-field"> <label for="confirm">[% loc('Again:') %]</label> <input type="password" name="confirm" value="[% confirm | html %]"> - <br> - - <label for="login"> </label> + </div> + <div class="checkbox"> <input type="submit" value="[% loc('Change Password') %]"> </div> + + </div> </form> diff --git a/templates/web/default/auth/general.html b/templates/web/default/auth/general.html index 32ea03177..5a5e63480 100644 --- a/templates/web/default/auth/general.html +++ b/templates/web/default/auth/general.html @@ -1,9 +1,9 @@ -[% INCLUDE 'header.html', title => loc('Login or create an account') %] - -<h1>[% loc('Login or create an account') %]</h1> +[% INCLUDE 'header.html', title = loc('Sign in or create an account') %] +<h1>[% loc('Sign in or create an account') %]</h1> <form action="[% c.uri_for() %]" method="post" name="general_auth"> +<input type="hidden" name="r" value="[% c.req.params.r | html %]"> [% IF email_error; @@ -18,33 +18,40 @@ END %] - <div> + <div id="fieldset"> [% IF loc_email_error %] - <span class="error">[% loc_email_error %]</span><br> + <div class="form-error">[% loc_email_error %]</div> [% ELSIF login_error %] - <span class="error">Email or password wrong - please try again.</span><br> + <div class="form-error">Email or password wrong - please try again.</div> [% END %] + <div class="form-field"> <label for="email">[% loc('Email:') %]</label> <input type="text" name="email" value="[% email || '' | html %]"> - <br> + </div> + <div class="form-field"> <label for="password">[% loc('Password:') %]</label> <input type="password" name="password" value=""> - <br> - - <label for="remember_me"> </label> - <input type="checkbox" name="remember_me" value='1' [% 'checked="checked"' IF remember_me %]> - Remember me - do not use on a public computer - <br> + </div> + + <div class="checkbox"> + <input type="checkbox" name="remember_me" value='1'[% ' checked' IF remember_me %]> + <label for="remember_me"> + [% loc('Remember me - do not use on a public computer') %] + </label> + </div> - <label for="login"> </label> - <input type="submit" name="login" value="[% loc('Log me in') %]"> + <div class="checkbox"> + <input type="submit" name="login" value="[% loc('Sign me in') %]"> + </div> <h3>I don't have an account, or I've forgotten my password...</h3> - <label for="email_login"> </label> + <div class="checkbox"> <input type="submit" name="email_login" value="[% loc('Email the details I need to the address I entered above') %]"> + </div> + </div> </form> diff --git a/templates/web/default/auth/logout.html b/templates/web/default/auth/logout.html index 9f3390f0a..3d8df60e4 100644 --- a/templates/web/default/auth/logout.html +++ b/templates/web/default/auth/logout.html @@ -1,8 +1,8 @@ -[% INCLUDE 'header.html', title => loc('Logout') %] +[% INCLUDE 'header.html', title => loc('Sign out') %] -<h1>[% loc('You have been logged out') %]</h1> +<h1>[% loc('You have been signed out') %]</h1> -<p>Please feel free to <a href="[% c.uri_for('/auth/') %]">login again</a>.</p> +<p>Please feel free to <a href="[% c.uri_for('/auth') %]">sign in again</a>.</p> -[% INCLUDE 'footer.html' %]
\ No newline at end of file +[% INCLUDE 'footer.html' %] diff --git a/templates/web/default/auth/token.html b/templates/web/default/auth/token.html index b3a3d5cc8..0f44d1074 100644 --- a/templates/web/default/auth/token.html +++ b/templates/web/default/auth/token.html @@ -16,9 +16,11 @@ <h1>[% loc('Please check your email') %]</h1> -<p>We have sent you an email containing a link to confirm your account.</p> +<p>[% loc("We have sent you an email containing a link to confirm your account.") %]</p> -<p>If you do not receive the email in the next few minutes please check your spam folder.</p> +<p>[% loc("The confirmation email <strong>may</strong> take a few minutes to arrive — <em>please</em> be patient.") %]</p> + +<p>[% loc("If you use web-based email or have 'junk mail' filters, you may wish to check your bulk/spam mail folders: sometimes, our messages are marked that way.") %]</p> [% END %] diff --git a/templates/web/default/email_sent.html b/templates/web/default/email_sent.html index 47a6f82cf..fd947022a 100644 --- a/templates/web/default/email_sent.html +++ b/templates/web/default/email_sent.html @@ -14,10 +14,6 @@ action => loc('your alert will not be activated'), worry => loc("we'll hang on to your alert while you're checking your email."), }, - tms => { - action => 'your expression of interest will not be registered', - worry => "we'll hang on to your expression of interest while you're checking your email.", - } } %] |