aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App.pm3
-rw-r--r--perllib/FixMyStreet/App/Controller/Auth.pm72
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm13
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm33
-rw-r--r--perllib/FixMyStreet/App/Controller/Tokens.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Abuse.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/AdminLog.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Alert.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/AlertSent.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/AlertType.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Contact.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/ContactsHistory.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Questionnaire.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Secret.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Session.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Token.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm12
-rw-r--r--perllib/FixMyStreet/Map/FMS.pm3
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm19
-rw-r--r--perllib/FixMyStreet/TestMech.pm13
22 files changed, 130 insertions, 114 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index b5838a169..47b290eff 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -61,8 +61,7 @@ __PACKAGE__->config(
credential => { # Catalyst::Authentication::Credential::Password
class => 'Password',
password_field => 'password',
- password_type => 'hashed',
- password_hash_type => 'SHA-1',
+ password_type => 'self_check',
},
store => { # Catalyst::Authentication::Store::DBIx::Class
class => 'DBIx::Class',
diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm
index 9ff415bf4..8aed746ec 100644
--- a/perllib/FixMyStreet/App/Controller/Auth.pm
+++ b/perllib/FixMyStreet/App/Controller/Auth.pm
@@ -7,7 +7,6 @@ BEGIN { extends 'Catalyst::Controller'; }
use Email::Valid;
use Net::Domain::TLD;
use mySociety::AuthToken;
-use Digest::SHA1 qw(sha1_hex);
=head1 NAME
@@ -15,14 +14,14 @@ FixMyStreet::App::Controller::Auth - Catalyst Controller
=head1 DESCRIPTION
-Controller for all the authentication related pages - create account, login,
-logout.
+Controller for all the authentication related pages - create account, sign in,
+sign out.
=head1 METHODS
=head2 index
-Present the user with a login / create account page.
+Present the user with a sign in / create account page.
=cut
@@ -37,25 +36,27 @@ sub general : Path : Args(0) {
return unless $req->method eq 'POST';
# decide which action to take
- $c->detach('email_login') if $req->param('email_login');
- $c->detach('login'); # default
+ $c->detach('email_sign_in') if $req->param('email_sign_in');
+
+ $c->forward( 'sign_in' )
+ && $c->detach( 'redirect_on_signin', [ $req->param('r') ] );
}
-=head2 login
+=head2 sign_in
-Allow the user to legin with a username and a password.
+Allow the user to sign in with a username and a password.
=cut
-sub login : Private {
- my ( $self, $c ) = @_;
+sub sign_in : Private {
+ my ( $self, $c, $email ) = @_;
- my $email = $c->req->param('email') || '';
- my $password = $c->req->param('password') || '';
- my $remember_me = $c->req->param('remember_me') || 0;
+ $email ||= $c->req->param('email') || '';
+ my $password = $c->req->param('password_sign_in') || '';
+ my $remember_me = $c->req->param('remember_me') || 0;
- # logout just in case
+ # Sign out just in case
$c->logout();
if ( $email
@@ -67,22 +68,22 @@ sub login : Private {
$c->set_session_cookie_expire(0)
unless $remember_me;
- $c->detach( 'redirect_on_signin', [ $c->req->param('r') ] );
+ return 1;
}
- # could not authenticate - show an error
- $c->stash->{login_error} = 1;
+ $c->stash->{sign_in_error} = 1;
+ return;
}
-=head2 email_login
+=head2 email_sign_in
-Email the user the details they need to log in. Don't check for an account - if
+Email the user the details they need to sign in. Don't check for an account - if
there isn't one we can create it when they come back with a token (which
contains the email addresss).
=cut
-sub email_login : Private {
+sub email_sign_in : Private {
my ( $self, $c ) = @_;
# check that the email is valid - otherwise flag an error
@@ -105,10 +106,12 @@ sub email_login : Private {
my $token_obj = $c->model('DB::Token') #
->create(
{
- scope => 'email_login',
+ scope => 'email_sign_in',
data => {
email => $good_email,
r => $c->req->param('r'),
+ name => $c->req->param('name'),
+ password => $c->req->param('password_register'),
}
}
);
@@ -120,7 +123,7 @@ sub email_login : Private {
=head2 token
-Handle the 'email_login' tokens. Find the account for the email address
+Handle the 'email_sign_in' tokens. Find the account for the email address
(creating if needed), authenticate the user and delete the token.
=cut
@@ -131,7 +134,7 @@ sub token : Path('/M') : Args(1) {
# retrieve the token or return
my $token_obj = $url_token
? $c->model('DB::Token')->find( {
- scope => 'email_login', token => $url_token
+ scope => 'email_sign_in', token => $url_token
} )
: undef;
@@ -140,20 +143,23 @@ sub token : Path('/M') : Args(1) {
return;
}
- # logout in case we are another user
+ # Sign out in case we are another user
$c->logout();
# get the email and scrap the token
- my $email = $token_obj->data->{email};
- my $redirect = $token_obj->data->{r};
+ my $data = $token_obj->data;
$token_obj->delete;
- # find or create the user related to the token and delete the token
- my $user = $c->model('DB::User')->find_or_create( { email => $email } );
+ # find or create the user related to the token.
+ my $user = $c->model('DB::User')->find_or_create( { email => $data->{email} } );
+ $user->name( $data->{name} ) if $data->{name};
+ $user->password( $data->{password} ) if $data->{password};
+ $user->update;
+
$c->authenticate( { email => $user->email }, 'no_password' );
# send the user to their page
- $c->detach( 'redirect_on_signin', [ $redirect ] );
+ $c->detach( 'redirect_on_signin', [ $data->{r} ] );
}
=head2 redirect_on_signin
@@ -171,7 +177,7 @@ sub redirect_on_signin : Private {
=head2 redirect
-Used when trying to view a page that requires login when you're not.
+Used when trying to view a page that requires sign in when you're not.
=cut
@@ -219,18 +225,18 @@ sub change_password : Local {
}
# we should have a usable password - save it to the user
- $c->user->obj->update( { password => sha1_hex($new) } );
+ $c->user->obj->update( { password => $new } );
$c->stash->{password_changed} = 1;
}
-=head2 logout
+=head2 sign_out
Log the user out. Tell them we've done so.
=cut
-sub logout : Local {
+sub sign_out : Local {
my ( $self, $c ) = @_;
$c->logout();
}
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 130eee858..a6be6c90c 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -28,8 +28,6 @@ Create a new report, or complete a partial one .
=head2 flow control
-submit_map: true if we reached this page by clicking on the map
-
submit_problem: true if a problem has been submitted
=head2 location (required)
@@ -564,7 +562,7 @@ sub process_user : Private {
unless $report->user;
# set the user's name and phone (if given)
- $report->user->name( Utils::trim_text( $params{name} ) );
+ $report->user->name( Utils::trim_text( $params{name} ) ) if $params{name};
$report->user->phone( Utils::trim_text( $params{phone} ) );
return 1;
@@ -912,9 +910,12 @@ sub redirect_or_confirm_creation : Private {
}
# otherwise create a confirm token and email it to them.
- my $token =
- $c->model("DB::Token")
- ->create( { scope => 'problem', data => $report->id } );
+ my $token = $c->model("DB::Token")->create( {
+ scope => 'problem',
+ data => {
+ id => $report->id
+ }
+ } );
$c->stash->{token_url} = $c->uri_for_email( '/P', $token->token );
$c->send_email( 'problem-confirm.txt', {
to => [ [ $report->user->email, $report->name ] ],
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 5421385fb..2d810d871 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -21,8 +21,8 @@ sub report_update : Path : Args(0) {
my ( $self, $c ) = @_;
$c->forward( '/report/load_problem_or_display_error', [ $c->req->param('id') ] )
- && $c->forward('process_user')
&& $c->forward('process_update')
+ && $c->forward('process_user')
&& $c->forward('/report/new/process_photo')
&& $c->forward('check_for_errors')
or $c->go( '/report/display', [ $c->req->param('id') ] );
@@ -90,28 +90,24 @@ Load user from the database or prepare a new one.
sub process_user : Private {
my ( $self, $c ) = @_;
- my $update_user;
- if ( $c->user ) {
-
- $update_user = $c->user->obj;
-
- } else {
+ my $update = $c->stash->{update};
- # Extract all the params to a hash to make them easier to work with
- my %params = #
- map { $_ => scalar $c->req->param($_) } #
- ( 'rznvy', 'name' );
+ $update->user( $c->user->obj ) if $c->user;
- # cleanup the email address
- my $email = $params{rznvy} ? lc $params{rznvy} : '';
- $email =~ s{\s+}{}g;
+ # Extract all the params to a hash to make them easier to work with
+ my %params = #
+ map { $_ => scalar $c->req->param($_) } #
+ ( 'rznvy', 'name' );
- $update_user = $c->model('DB::User')->find_or_new( { email => $email } );
- $update_user->name( Utils::trim_text( $params{name} ) );
+ # cleanup the email address
+ my $email = $params{rznvy} ? lc $params{rznvy} : '';
+ $email =~ s{\s+}{}g;
- }
+ $update->user( $c->model('DB::User')->find_or_new( { email => $email } ) )
+ unless $update->user;
- $c->stash->{update_user} = $update_user;
+ $update->user->name( Utils::trim_text( $params{name} ) )
+ if $params{name};
return 1;
}
@@ -146,7 +142,6 @@ sub process_update : Private {
text => $params{update},
name => $name,
problem => $c->stash->{problem},
- user => $c->stash->{update_user},
state => 'unconfirmed',
mark_fixed => $params{fixed} ? 1 : 0,
cobrand => $c->cobrand->moniker,
diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm
index 111508e60..c9c9f3ab7 100644
--- a/perllib/FixMyStreet/App/Controller/Tokens.pm
+++ b/perllib/FixMyStreet/App/Controller/Tokens.pm
@@ -32,7 +32,7 @@ sub confirm_problem : Path('/P') {
$c->forward( 'load_auth_token', [ $token_code, 'problem' ] );
# Load the problem
- my $problem_id = $auth_token->data;
+ my $problem_id = $auth_token->data->{id};
my $problem = $c->cobrand->problems->find( { id => $problem_id } )
|| $c->detach('token_error');
$c->stash->{problem} = $problem;
diff --git a/perllib/FixMyStreet/DB/Result/Abuse.pm b/perllib/FixMyStreet/DB/Result/Abuse.pm
index df3ebe24a..b1cf9c1ed 100644
--- a/perllib/FixMyStreet/DB/Result/Abuse.pm
+++ b/perllib/FixMyStreet/DB/Result/Abuse.pm
@@ -8,14 +8,14 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("abuse");
__PACKAGE__->add_columns("email", { data_type => "text", is_nullable => 0 });
__PACKAGE__->set_primary_key("email");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-24 15:32:43
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Bc0deuJiQlKyMGzLTUAIxg
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IuTLiJSDZGLF/WX8q3iKIQ
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
diff --git a/perllib/FixMyStreet/DB/Result/AdminLog.pm b/perllib/FixMyStreet/DB/Result/AdminLog.pm
index e57773e63..da97950a0 100644
--- a/perllib/FixMyStreet/DB/Result/AdminLog.pm
+++ b/perllib/FixMyStreet/DB/Result/AdminLog.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("admin_log");
__PACKAGE__->add_columns(
"id",
@@ -36,8 +36,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-06 18:52:09
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:VKN3o9SHoDhG2/H5NInf2w
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7427CuN3/6IL2GxiQDoWUA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Alert.pm b/perllib/FixMyStreet/DB/Result/Alert.pm
index 3a2dc9a9f..eddd98f37 100644
--- a/perllib/FixMyStreet/DB/Result/Alert.pm
+++ b/perllib/FixMyStreet/DB/Result/Alert.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("alert");
__PACKAGE__->add_columns(
"id",
@@ -64,8 +64,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-03 16:48:36
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NlyhWyg0NrH5/kZYYO36qg
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:d2TrE9UIZdXu3eXYJH0Zmw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/AlertSent.pm b/perllib/FixMyStreet/DB/Result/AlertSent.pm
index 85a9000d5..a901c2fde 100644
--- a/perllib/FixMyStreet/DB/Result/AlertSent.pm
+++ b/perllib/FixMyStreet/DB/Result/AlertSent.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("alert_sent");
__PACKAGE__->add_columns(
"alert_id",
@@ -30,8 +30,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-03 16:48:36
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:x1nMIiNFSTKxdPxZmko18Q
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fTiWIoriQUvHpWc9PpFLvA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/AlertType.pm b/perllib/FixMyStreet/DB/Result/AlertType.pm
index 7a3cd1e36..d23a2983d 100644
--- a/perllib/FixMyStreet/DB/Result/AlertType.pm
+++ b/perllib/FixMyStreet/DB/Result/AlertType.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("alert_type");
__PACKAGE__->add_columns(
"ref",
@@ -47,8 +47,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-03 16:48:36
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KNZ7eWU/VgF8xzsjCHKVjw
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+PKqo7IZ4MlM9ur4V2P9tA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 76c96e581..9ed9d8b48 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("comment");
__PACKAGE__->add_columns(
"id",
diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm
index 2b18e0250..001fb4ac6 100644
--- a/perllib/FixMyStreet/DB/Result/Contact.pm
+++ b/perllib/FixMyStreet/DB/Result/Contact.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("contacts");
__PACKAGE__->add_columns(
"id",
@@ -39,7 +39,7 @@ __PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("contacts_area_id_category_idx", ["area_id", "category"]);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-24 15:32:43
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8u8S4QtIf0n7QUxVuP/Siw
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BXGd4uk1ybC5RTKlInTr0w
1;
diff --git a/perllib/FixMyStreet/DB/Result/ContactsHistory.pm b/perllib/FixMyStreet/DB/Result/ContactsHistory.pm
index 4fa74a9a2..811a06b44 100644
--- a/perllib/FixMyStreet/DB/Result/ContactsHistory.pm
+++ b/perllib/FixMyStreet/DB/Result/ContactsHistory.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("contacts_history");
__PACKAGE__->add_columns(
"contacts_history_id",
@@ -40,8 +40,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("contacts_history_id");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-02 18:27:49
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:D9Uu5Lp8BackyZdLXJDIvw
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9APvBwAOebG5g4MGxJuVKQ
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index fa3772310..1c8487ae7 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("problem");
__PACKAGE__->add_columns(
"id",
@@ -100,8 +100,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-24 15:32:43
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:U3aYCRwE4etekKaHdhEkIw
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3sw/1dqxlTvcWEI/eJTm4w
# Add fake relationship to stored procedure table
__PACKAGE__->has_many(
diff --git a/perllib/FixMyStreet/DB/Result/Questionnaire.pm b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
index 5a507645f..cc4ec300b 100644
--- a/perllib/FixMyStreet/DB/Result/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("questionnaire");
__PACKAGE__->add_columns(
"id",
@@ -40,8 +40,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-24 15:32:43
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BAWTYKAQ84VeOI6D2gtQOQ
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QNFqqCg6J4SFlg4zwm7TWw
use DateTime::TimeZone;
diff --git a/perllib/FixMyStreet/DB/Result/Secret.pm b/perllib/FixMyStreet/DB/Result/Secret.pm
index 399f0be18..8a1fa671d 100644
--- a/perllib/FixMyStreet/DB/Result/Secret.pm
+++ b/perllib/FixMyStreet/DB/Result/Secret.pm
@@ -8,13 +8,13 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("secret");
__PACKAGE__->add_columns("secret", { data_type => "text", is_nullable => 0 });
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-03 12:02:18
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Htl6+DHfHy9l+bjBxAbH6Q
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:MfqW1K0aFtwpa/1c/UwHjg
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Session.pm b/perllib/FixMyStreet/DB/Result/Session.pm
index a10e6fa0d..9d5d509dc 100644
--- a/perllib/FixMyStreet/DB/Result/Session.pm
+++ b/perllib/FixMyStreet/DB/Result/Session.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("sessions");
__PACKAGE__->add_columns(
"id",
@@ -21,8 +21,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-24 15:32:43
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tYWQtbja2nkA/2A+kaPl1g
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TagSQOXnDttkwfJ7oDH8Yw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
diff --git a/perllib/FixMyStreet/DB/Result/Token.pm b/perllib/FixMyStreet/DB/Result/Token.pm
index d838e9fc2..3a900858d 100644
--- a/perllib/FixMyStreet/DB/Result/Token.pm
+++ b/perllib/FixMyStreet/DB/Result/Token.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("token");
__PACKAGE__->add_columns(
"scope",
@@ -27,8 +27,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("scope", "token");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-24 15:32:43
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ET4L1y6yWmEUDKPKa7wJiw
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:frl+na3HrIzGw9D1t891nA
# Trying not to use this
# use mySociety::DBHandle qw(dbh);
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index dfcb18c5b..c0b078775 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -8,7 +8,7 @@ use warnings;
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime");
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("users");
__PACKAGE__->add_columns(
"id",
@@ -54,6 +54,16 @@ __PACKAGE__->has_many(
# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-22 16:10:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:zQIniwAXjl5Lh9wyiGuwFw
+__PACKAGE__->add_columns(
+ "password" => {
+ encode_column => 1,
+ encode_class => 'Crypt::Eksblowfish::Bcrypt',
+ encode_args => { cost => 8 },
+ encode_check_method => 'check_password',
+ },
+);
+>>>>>>> 62ffebc89cc66d32a828ea1de8c850c3e950faa1
+
use mySociety::EmailUtil;
=head2 check_for_errors
diff --git a/perllib/FixMyStreet/Map/FMS.pm b/perllib/FixMyStreet/Map/FMS.pm
index d0a28be9b..a5a2dd9f0 100644
--- a/perllib/FixMyStreet/Map/FMS.pm
+++ b/perllib/FixMyStreet/Map/FMS.pm
@@ -11,9 +11,6 @@ use base 'FixMyStreet::Map::OSM';
use strict;
-use constant ZOOM_LEVELS => 5;
-use constant MIN_ZOOM_LEVEL => 13;
-
# Is set by the JavaScript
sub map_type {
return '""';
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index 4543ce2da..9b968b4f6 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -51,10 +51,17 @@ sub copyright {
sub display_map {
my ($self, $c, %params) = @_;
+ my $numZoomLevels = ZOOM_LEVELS;
+ my $zoomOffset = MIN_ZOOM_LEVEL;
+ if ($params{any_zoom}) {
+ $numZoomLevels = 18;
+ $zoomOffset = 0;
+ }
+
# Adjust zoom level dependent upon population density
my $dist = mySociety::Gaze::get_radius_containing_population( $params{latitude}, $params{longitude}, 200_000 );
- my $default_zoom = ZOOM_LEVELS - 3;
- $default_zoom = ZOOM_LEVELS - 2 if $dist < 10;
+ my $default_zoom = $numZoomLevels - 3;
+ $default_zoom = $numZoomLevels - 2 if $dist < 10;
# Map centre may be overridden in the query string
$params{latitude} = Utils::truncate_coordinate($c->req->params->{lat} + 0)
@@ -63,9 +70,9 @@ sub display_map {
if defined $c->req->params->{lon};
my $zoom = defined $c->req->params->{zoom} ? $c->req->params->{zoom} + 0 : $default_zoom;
- $zoom = ZOOM_LEVELS - 1 if $zoom >= ZOOM_LEVELS;
+ $zoom = $numZoomLevels - 1 if $zoom >= $numZoomLevels;
$zoom = 0 if $zoom < 0;
- my $zoom_act = MIN_ZOOM_LEVEL + $zoom;
+ my $zoom_act = $zoomOffset + $zoom;
my ($x_tile, $y_tile) = latlon_to_tile_with_adjust($params{latitude}, $params{longitude}, $zoom_act);
foreach my $pin (@{$params{pins}}) {
@@ -82,7 +89,8 @@ sub display_map {
y_tile => $y_tile,
zoom => $zoom,
zoom_act => $zoom_act,
- zoom_levels => ZOOM_LEVELS,
+ zoomOffset => $zoomOffset,
+ numZoomLevels => $numZoomLevels,
compass => compass( $x_tile, $y_tile, $zoom_act ),
};
}
@@ -158,6 +166,7 @@ sub click_to_tile {
# Given some click co-ords (the tile they were on, and where in the
# tile they were), convert to WGS84 and return.
+# XXX Note use of MIN_ZOOM_LEVEL here.
sub click_to_wgs84 {
my ($self, $c, $pin_tile_x, $pin_x, $pin_tile_y, $pin_y) = @_;
my $tile_x = click_to_tile($pin_tile_x, $pin_x);
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index 3dd4e84e9..1391254b6 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -14,7 +14,6 @@ use Test::More;
use Web::Scraper;
use Carp;
use Email::Send::Test;
-use Digest::SHA1 'sha1_hex';
use JSON;
=head1 NAME
@@ -89,18 +88,18 @@ sub log_in_ok {
my $user = $mech->create_user_ok($email);
# store the old password and then change it
- my $old_password_sha1 = $user->password;
- $user->update( { password => sha1_hex('secret') } );
+ my $old_password = $user->password;
+ $user->update( { password => 'secret' } );
# log in
$mech->get_ok('/auth');
$mech->submit_form_ok(
- { with_fields => { email => $email, password => 'secret' } },
- "login using form" );
+ { with_fields => { email => $email, password_sign_in => 'secret' } },
+ "sign in using form" );
$mech->logged_in_ok;
# restore the password (if there was one)
- $user->update( { password => $old_password_sha1 } ) if $old_password_sha1;
+ $user->update( { password => $old_password } ) if $old_password;
return $user;
}
@@ -115,7 +114,7 @@ Log out the current user
sub log_out_ok {
my $mech = shift;
- $mech->get_ok('/auth/logout');
+ $mech->get_ok('/auth/sign_out');
$mech->not_logged_in_ok;
}