Only allow owner (creator) to set a passord

master
Daniel Berteaud 11 years ago
parent 065eac4be5
commit 76468a8958
  1. 26
      public/js/vroom.js
  2. 19
      public/vroom.pl

@ -608,14 +608,19 @@ function initVroom(room) {
password: pass, password: pass,
room: roomName room: roomName
}, },
error: function(data) { error: function() {
var msg = (data && data.msg) ? data.msg : locale.ERROR_OCCURED; var msg = locale.ERROR_OCCURED;
$.notify(msg, 'error'); $.notify(msg, 'error');
}, },
success: function(data) { success: function(data) {
$.notify(data.msg, 'success');
$('#joinPass').val(''); $('#joinPass').val('');
webrtc.sendToAll('password_protect_on', {}); if (data.status == 'success'){
$.notify(data.msg, 'success');
webrtc.sendToAll('password_protect_on', {});
}
else{
$.notify(data.msg, 'error');
}
} }
}); });
}); });
@ -627,14 +632,19 @@ function initVroom(room) {
action: 'setJoinPassword', action: 'setJoinPassword',
room: roomName room: roomName
}, },
error: function(data) { error: function() {
var msg = (data && data.msg) ? data.msg : locale.ERROR_OCCURED; var msg = locale.ERROR_OCCURED;
$.notify(msg, 'error'); $.notify(msg, 'error');
}, },
success: function(data) { success: function(data) {
$.notify(data.msg, 'success');
$('#joinPass').val(''); $('#joinPass').val('');
webrtc.sendToAll('password_protect_off', {}); if (data.status == 'success'){
$.notify(data.msg, 'success');
webrtc.sendToAll('password_protect_off', {});
}
else{
$.notify(data.msg, 'error');
}
} }
}); });
}); });

@ -296,6 +296,7 @@ post '/create' => sub {
$self->res->headers->cache_control('max-age=1, no-cache'); $self->res->headers->cache_control('max-age=1, no-cache');
my $name = $self->param('roomName') || $self->get_random_name(); my $name = $self->param('roomName') || $self->get_random_name();
$self->login; $self->login;
$self->session($name => {role => 'owner'});
unless ($self->valid_room_name($name)){ unless ($self->valid_room_name($name)){
return $self->render('error', return $self->render('error',
room => $name, room => $name,
@ -490,20 +491,28 @@ post '/action' => sub {
} }
elsif ($action eq 'setJoinPassword'){ elsif ($action eq 'setJoinPassword'){
my $pass = $self->param('password'); my $pass = $self->param('password');
$pass = undef if ($pass eq ''); $pass = undef if ($pass && $pass eq '');
my $res = $self->set_join_pass($room,$pass); my $res = undef;
my $errmsg = 'ERROR_OCCURED';
if ($self->session($room)->{role} eq 'owner'){
$res = $self->set_join_pass($room,$pass);
}
else{
$errmsg = 'NOT_ALLOWED';
}
if (!$res){ if (!$res){
return $self->render( return $self->render(
json => { json => {
msg => $self->l('ERROR_OCCURED'), msg => $self->l($errmsg),
status => 'error'
}, },
status => '500'
); );
} }
else{ else{
return $self->render( return $self->render(
json => { json => {
msg => ($pass) ? $self->l('JOIN_PASSWORD_SET') : $self->l('JOIN_PASSWORD_REMOVED'), msg => ($pass) ? $self->l('JOIN_PASSWORD_SET') : $self->l('JOIN_PASSWORD_REMOVED'),
status => 'success'
} }
); );
} }

Loading…
Cancel
Save