1
0
mirror of https://github.com/dani/vroom.git synced 2024-06-26 17:43:29 +02:00

HTTP codes for room creation

This commit is contained in:
Daniel Berteaud 2015-02-04 22:44:16 +01:00
parent d4db36765a
commit 2ebe33060b
2 changed files with 13 additions and 12 deletions

View File

@ -348,23 +348,24 @@ 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' ){
room = data.room;
window.location.assign(rootUrl + data.room);
},
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(){
$.notify(locale.ERROR_OCCURRED, 'error');
else{
$.notify(locale.ERROR_OCCURRED, 'error');
}
}
});
}

View File

@ -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} = '';