Fix room creation

master
Daniel Berteaud 10 years ago
parent 33db43e2b0
commit 944f153d21
  1. 16
      vroom.pl

@ -1024,14 +1024,13 @@ post '/create' => sub {
$json->{msg} = $self->l('ERROR_NAME_CONFLICT'); $json->{msg} = $self->l('ERROR_NAME_CONFLICT');
return $self->render(json => $json); return $self->render(json => $json);
} }
my $res = $self->create_room($name,$self->session('name')); if (!$self->create_room($name,$self->session('name'))){
if (!$res->{ok}){ $json->{err} = 'ERROR_OCCURRED';
$json->{err} = $res->{msg}; $json->{msg} = $self->l('ERROR_OCCURRED');
$json->{msg} = $self->l($res->{msg});
return $self->render(json => $json); return $self->render(json => $json);
} }
$json->{status} = 'success'; $json->{status} = 'success';
$json->{err} = $res->{msg}; $json->{err} = '';
$self->session($name => {role => 'owner'}); $self->session($name => {role => 'owner'});
return $self->render(json => $json); return $self->render(json => $json);
}; };
@ -1157,11 +1156,10 @@ get '/(*room)' => sub {
# Short life cookie to negociate a session with the signaling server # Short life cookie to negociate a session with the signaling server
$self->cookie(vroomsession => encode_base64($self->session('name') . ':' . $data->{name} . ':' . $data->{token}, ''), {expires => time + 60, path => '/'}); $self->cookie(vroomsession => encode_base64($self->session('name') . ':' . $data->{name} . ':' . $data->{token}, ''), {expires => time + 60, path => '/'});
# Add this user to the participants table # Add this user to the participants table
$res = $self->add_participant_to_room($room,$self->session('name')); if (!$self->add_participant_to_room($room,$self->session('name'))){
if (!$res->{ok}){
return $self->render('error', return $self->render('error',
msg => $self->l($res->{msg}), msg => $self->l('ERROR_OCCURRED'),
err => $res->{msg}, err => 'ERROR_OCCURRED',
room => $room room => $room
); );
} }

Loading…
Cancel
Save