Only the owner is allowed to lock/unlock a room

master
Daniel Berteaud 11 years ago
parent 96d8a0eaa6
commit 1695c9dfff
  1. 27
      public/vroom.pl

@ -504,28 +504,19 @@ post '/action' => sub {
} }
if ($action =~ m/(un)?lock/){ if ($action =~ m/(un)?lock/){
my ($lock,$success); my ($lock,$success);
if ($action eq 'lock'){ my $msg = 'ERROR_OCCURED';
$lock = 1; my $status = 'error';
$success = $self->l('ROOM_LOCKED'); if (!$self->session($room) || $self->session($room)->{role} ne 'owner'){
} $msg = 'NOT_ALLOWED';
else{
$lock = 0;
$success = $self->l('ROOM_UNLOCKED');
} }
my $room = $self->param('room'); elsif ($self->lock_room($room,($action eq 'lock') ? '1':'0')){
my $res = $self->lock_room($room,$lock); $status = 'success';
unless ($res){ $msg = ($action eq 'lock') ? 'ROOM_LOCKED' : 'ROOM_UNLOCKED';
return $self->render(
json => {
msg => $self->l('ERROR_OCCURED'),
status => 'error'
},
);
} }
return $self->render( return $self->render(
json => { json => {
msg => $success, msg => $self->l($msg),
status => 'success' status => $status
} }
); );
} }

Loading…
Cancel
Save