HTTP codes for room creation

master
Daniel Berteaud 10 years ago
parent d4db36765a
commit 2ebe33060b
  1. 13
      public/js/vroom.js
  2. 6
      vroom.pl

@ -348,24 +348,25 @@ function initIndex(){
roomName: $('#roomName').val(),
},
success: function(data) {
if (data.status == 'success'){
room = data.room;
window.location.assign(rootUrl + data.room);
}
else if (data.err && data.err == 'ERROR_NAME_CONFLICT' ){
},
error: function(data){
data = data.responseJSON;
if (data.err && data.err == 'ERROR_NAME_CONFLICT' ){
room = data.room;
$('#conflictModal').modal('show');
}
else{
else if (data.msg){
$('#roomName').parent().parent().notify(data.msg, {
class: 'error',
position: 'bottom center'
});
}
},
error: function(){
else{
$.notify(locale.ERROR_OCCURRED, 'error');
}
}
});
}
});

@ -1139,17 +1139,17 @@ post '/create' => sub {
if (!$self->valid_room_name($name)){
$json->{err} = 'ERROR_NAME_INVALID';
$json->{msg} = $self->l('ERROR_NAME_INVALID');
return $self->render(json => $json);
return $self->render(json => $json, status => 400);
}
elsif ($self->get_room_by_name($name)){
$json->{err} = 'ERROR_NAME_CONFLICT';
$json->{msg} = $self->l('ERROR_NAME_CONFLICT');
return $self->render(json => $json);
return $self->render(json => $json, status => 409);
}
if (!$self->create_room($name,$self->session('name'))){
$json->{err} = 'ERROR_OCCURRED';
$json->{msg} = $self->l('ERROR_OCCURRED');
return $self->render(json => $json);
return $self->render(json => $json, status => 500);
}
$json->{status} = 'success';
$json->{err} = '';

Loading…
Cancel
Save