diff options
author | pezholio <pezholio@gmail.com> | 2017-01-18 14:44:04 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2017-02-15 13:31:44 +0000 |
commit | 3010d13823de9833700b18bf4ac3e71437d9001f (patch) | |
tree | adb5d5c899597a9a83c1bdfcc8a64fe2d33c9e97 /perllib/FixMyStreet | |
parent | 2a099bc9b33ed0b40234a7070437f4defb44ce4b (diff) |
Add Problem->tokenised_url for logging user in
This method creates a token that logs the reporting user in, optionally
with some parameters which are stored with the token for use when redirecting
after login.
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index d0a5a3a4f..97cb28fe8 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -182,6 +182,8 @@ use Utils; use FixMyStreet::Map::FMS; use LWP::Simple qw($ua); use RABX; +use URI; +use URI::QueryParam; my $IM = eval { require Image::Magick; @@ -511,6 +513,30 @@ sub admin_url { return $cobrand->admin_base_url . '/report_edit/' . $self->id; } +=head2 tokenised_url + +Return a url for this problem report that logs a user in + +=cut + +sub tokenised_url { + my ($self, $user, $params) = @_; + + my $token = FixMyStreet::App->model('DB::Token')->create( + { + scope => 'email_sign_in', + data => { + id => $self->id, + email => $user->email, + r => $self->url, + p => $params, + } + } + ); + + return "/M/". $token->token; +} + =head2 is_open Returns 1 if the problem is in a open state otherwise 0. |