Cleanup setPassword handler

master
Daniel Berteaud 11 years ago
parent 7222122f23
commit 8122691209
  1. 31
      public/vroom.pl

@ -552,7 +552,8 @@ post '/action' => sub {
my $type = $self->param('type') || 'join'; my $type = $self->param('type') || 'join';
$pass = undef if ($pass && $pass eq ''); $pass = undef if ($pass && $pass eq '');
my $res = undef; my $res = undef;
my $errmsg = 'ERROR_OCCURED'; my $msg = 'ERROR_OCCURED';
my $status = 'error';
if ($self->session($room)->{role} eq 'owner'){ if ($self->session($room)->{role} eq 'owner'){
if ($type eq 'owner'){ if ($type eq 'owner'){
$res = $self->set_owner_pass($room,$pass); $res = $self->set_owner_pass($room,$pass);
@ -560,26 +561,20 @@ post '/action' => sub {
else{ else{
$res = $self->set_join_pass($room,$pass); $res = $self->set_join_pass($room,$pass);
} }
if ($res){
$msg = ($pass) ? $self->l('PASSWORD_SET') : $self->l('PASSWORD_REMOVED');
$status = 'success';
}
} }
else{ else{
$errmsg = 'NOT_ALLOWED'; $msg = 'NOT_ALLOWED';
}
if (!$res){
return $self->render(
json => {
msg => $self->l($errmsg),
status => 'error'
},
);
}
else{
return $self->render(
json => {
msg => ($pass) ? $self->l('PASSWORD_SET') : $self->l('PASSWORD_REMOVED'),
status => 'success'
}
);
} }
return $self->render(
json => {
msg => $msg,
status => $status
}
);
} }
elsif ($action eq 'authenticate'){ elsif ($action eq 'authenticate'){
my $pass = $self->param('password'); my $pass = $self->param('password');

Loading…
Cancel
Save