diff --git a/public/vroom.pl b/public/vroom.pl index 7bcb372..dea1f75 100755 --- a/public/vroom.pl +++ b/public/vroom.pl @@ -476,7 +476,7 @@ helper add_invitation => sub { my ($room,$email) = @_; my $from = $self->session('name') || return undef; my $data = $self->get_room($room); - my $id = $self->get_random(20); + my $id = $self->get_random(30); return undef unless ($data); my $sth = eval { $self->db->prepare("INSERT INTO `invitations` (`id`,`from`,`token`,`email`,`timestamp`) VALUES (?,?,?,?,?)") } || return undef; $sth->execute($data->{id},$from,$id,$email,time()) || return undef; @@ -620,11 +620,12 @@ get '/kicked/(:room)' => sub { # Route for invitition response get '/invitation' => sub { my $self = shift; - my $inviteId = $self->param('id') || ''; - my $response = $self->param('response') || 'decline'; + my $inviteId = $self->param('token') || ''; + # Delecte expired invitation now + $self->delete_invitations; my $invite = $self->get_invitation($inviteId); my $room = $self->get_room_by_id($invite->{id}); - if (!$invite || !$room || $response !~ m/^(decline|later)$/){ + if (!$invite || !$room){ return $self->render('error', err => 'ERROR_INVITATION_INVALID', msg => $self->l('ERROR_INVITATION_INVALID'), @@ -634,13 +635,12 @@ get '/invitation' => sub { $self->render('invitation', inviteId => $inviteId, room => $room->{name}, - response => $response ); }; post '/invitation' => sub { my $self = shift; - my $id = $self->param('id') || ''; + my $id = $self->param('token') || ''; my $response = $self->param('response') || 'decline'; my $message = $self->param('message') || ''; if ($response !~ m/^(later|decline)$/ || !$self->respond_invitation($id,$response,$message)){ @@ -755,6 +755,7 @@ get '/(*room)' => sub { $self->redirect_to($self->get_url('/') . lc $room); } $self->delete_rooms; + $self->delete_invitations; unless ($self->valid_room_name($room)){ return $self->render('error', msg => $self->l('ERROR_NAME_INVALID'), @@ -782,6 +783,7 @@ get '/(*room)' => sub { ); } # Now, if the room is password protected and we're not a participant, nor the owner, lets prompt for the password + # Email invitation have a token which can be used instead of password if ($data->{join_password} && (!$self->session($room) || $self->session($room)->{role} !~ m/^participant|owner$/) && !$self->check_invite_token($room,$token)){ @@ -864,7 +866,8 @@ post '/action' => sub { template => 'invite', room => $room, message => $message, - inviteId => $inviteId + inviteId => $inviteId, + joinPass => ($data->{join_password}) ? 'yes' : 'no' ], )){ $self->app->log->info($self->session('name') . " sent an invitation for room $room to $rcpt"); diff --git a/templates/default/invitation.html.ep b/templates/default/invitation.html.ep index f3cf8fe..cc68584 100644 --- a/templates/default/invitation.html.ep +++ b/templates/default/invitation.html.ep @@ -26,16 +26,16 @@
- +

<%=l 'CLICK_SEND_OR_JOIN_NOW' %>

- - + <%=l 'JOIN_THIS_ROOM' %> +
diff --git a/templates/default/invite.email_html.ep b/templates/default/invite.email_html.ep index 20af1cf..0682585 100644 --- a/templates/default/invite.email_html.ep +++ b/templates/default/invite.email_html.ep @@ -20,8 +20,13 @@ <%=l 'WHEN_YOU_ARE_READY' %>

- - <%= $url . $room %>?token=<%= $inviteId %> + <% my $roomAccess = $room; + if ($joinPass eq 'yes') { + $roomAccess .= '?token=' . $inviteId; + } + %> + + <%= $url . $roomAccess %>

@@ -37,7 +42,7 @@

<%=l 'IF_YOU_CANNOT_JOIN' %>

- + <%=l 'YOU_CAN_NOTIFY_THE_ORGANIZER' %>

diff --git a/templates/default/invite.email_text.ep b/templates/default/invite.email_text.ep index 1f9a4bc..a80ed3c 100644 --- a/templates/default/invite.email_text.ep +++ b/templates/default/invite.email_text.ep @@ -10,7 +10,12 @@ <%==l 'WHEN_YOU_ARE_READY' %> -<%= $url . $room %>?token=<%= $inviteId %> +<% my $roomAccess = $room; + if ($joinPass eq 'yes') { + $roomAccess .= '?token=' . $inviteId; + } +%> +<%== $url . $roomAccess %> <% if ($message && $message ne ''){ %> <%==l 'MESSAGE_FROM_ORGANIZER' %>: @@ -20,7 +25,7 @@ <%==l 'IF_YOU_CANNOT_JOIN' %> <%==l 'YOU_CAN_NOTIFY_THE_ORGANIZER' %> -<%== $url . 'invitation?id=' . $inviteId %> +<%== $url . 'invitation?token=' . $inviteId %> <%==l 'HAVE_A_NICE_MEETING' %> --