journey: add token to share link if non-public
This commit is contained in:
parent
d58c5a8826
commit
ba483a9daf
2 changed files with 30 additions and 3 deletions
|
@ -479,6 +479,26 @@ sub status_token_ok {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub journey_token_ok {
|
||||||
|
my ( $self, $journey, $ts2_ext ) = @_;
|
||||||
|
my $token = $self->param('token') // q{};
|
||||||
|
|
||||||
|
my ( $eva, $ts, $ts2 ) = split( qr{-}, $token );
|
||||||
|
if ( not $ts ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ts2 //= $ts2_ext;
|
||||||
|
|
||||||
|
if ( $eva == $journey->{from_eva}
|
||||||
|
and $ts == $journey->{checkin_ts}
|
||||||
|
and $ts2 == $journey->{sched_dep_ts} )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sub user_status {
|
sub user_status {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
|
@ -507,6 +527,8 @@ sub user_status {
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ( $candidate->{sched_dep_ts} eq $ts ) {
|
if ( $candidate->{sched_dep_ts} eq $ts ) {
|
||||||
|
|
||||||
|
# TODO pass token
|
||||||
$self->redirect_to("/p/${name}/j/$candidate->{id}");
|
$self->redirect_to("/p/${name}/j/$candidate->{id}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -707,11 +729,11 @@ sub public_journey_details {
|
||||||
not(
|
not(
|
||||||
$visibility eq 'public'
|
$visibility eq 'public'
|
||||||
or ( $visibility eq 'unlisted'
|
or ( $visibility eq 'unlisted'
|
||||||
and $self->status_token_ok($journey) )
|
and $self->journey_token_ok($journey) )
|
||||||
or (
|
or (
|
||||||
$visibility eq 'travelynx'
|
$visibility eq 'travelynx'
|
||||||
and ( $self->is_user_authenticated
|
and ( $self->is_user_authenticated
|
||||||
or $self->status_token_ok($journey) )
|
or $self->journey_token_ok($journey) )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -246,7 +246,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col s12 m6 l6 center-align">
|
<div class="col s12 m6 l6 center-align">
|
||||||
<a class="btn waves-effect waves-light action-share"
|
<a class="btn waves-effect waves-light action-share"
|
||||||
|
% if ($journey_visibility eq 'public') {
|
||||||
data-url="<%= url_for('public_journey', name => current_user()->{name}, id => $journey->{id} )->to_abs->scheme('https'); %>"
|
data-url="<%= url_for('public_journey', name => current_user()->{name}, id => $journey->{id} )->to_abs->scheme('https'); %>"
|
||||||
|
% }
|
||||||
|
% else {
|
||||||
|
data-url="<%= url_for('public_journey', name => current_user()->{name}, id => $journey->{id} )->to_abs->scheme('https'); %>?token=<%= $journey->{from_eva} %>-<%= $journey->{checkin_ts} %>-<%= $journey->{sched_dep_ts} %>"
|
||||||
|
% }
|
||||||
data-text="<%= stash('share_text') %>"
|
data-text="<%= stash('share_text') %>"
|
||||||
>
|
>
|
||||||
<i class="material-icons left" aria-hidden="true">share</i> Teilen
|
<i class="material-icons left" aria-hidden="true">share</i> Teilen
|
||||||
|
|
Loading…
Reference in a new issue