mirror of
https://github.com/dani/vroom.git
synced 2024-06-23 18:19:12 +02:00
More fixes for the admin interface
Make a new get_room_conf API call which does more or less the same as get_room_info but without trying to get our role
This commit is contained in:
parent
22e8dc1ef5
commit
7d98c994c9
|
@ -169,6 +169,7 @@ use constant API_ACTIONS => {
|
|||
ping => 1,
|
||||
authenticate => 1,
|
||||
get_room_info => 1,
|
||||
get_room_conf => 1,
|
||||
get_peer_role => 1,
|
||||
join => 1,
|
||||
get_padd_session => 1
|
||||
|
|
|
@ -319,6 +319,35 @@ function initAdmin(){
|
|||
});
|
||||
}
|
||||
|
||||
function getRoomConf(roomName){
|
||||
$.ajax({
|
||||
data: {
|
||||
req: JSON.stringify({
|
||||
action: 'get_room_conf',
|
||||
param: {
|
||||
room: roomName,
|
||||
}
|
||||
})
|
||||
},
|
||||
async: false,
|
||||
error: function(data){
|
||||
$.notify(locale.ERROR_OCCURRED, 'error');
|
||||
},
|
||||
success: function(data){
|
||||
// Update config switches
|
||||
$('#lockedSet').bootstrapSwitch('state', data.locked == 'yes');
|
||||
$('#askForNameSet').bootstrapSwitch('state', data.ask_for_name == 'yes');
|
||||
$('#joinPassSet').bootstrapSwitch('state', data.join_auth == 'yes');
|
||||
$('#ownerPassSet').bootstrapSwitch('state', data.owner_auth == 'yes');
|
||||
$('#configureModal').modal('show');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('click', '.btn-configure', function(){
|
||||
getRoomConf($(this).data('room'));
|
||||
});
|
||||
|
||||
// Get room list right after loading the page
|
||||
getRooms();
|
||||
}
|
||||
|
|
18
vroom.pl
18
vroom.pl
|
@ -942,6 +942,7 @@ helper make_key_admin => sub {
|
|||
my $self = shift;
|
||||
my ($token) = @_;
|
||||
my $key = $self->get_key_by_token($token);
|
||||
$self->app->log->debug("making key $token an admin key");
|
||||
if (!$key){
|
||||
return 0;
|
||||
}
|
||||
|
@ -1031,8 +1032,8 @@ get '/admin/:room' => { room => '' } => sub {
|
|||
my $room = $self->stash('room');
|
||||
# Someone accessing /admin is considered an admin
|
||||
# For now, the auth is handled outside of VROOM itself
|
||||
my $token = $self->req->headers->header('X-VROOM-API-Key');
|
||||
$self->make_key_admin($token);
|
||||
$self->login;
|
||||
$self->make_key_admin($self->session('key'));
|
||||
if ($room eq ''){
|
||||
$self->purge_rooms;
|
||||
return $self->render('admin');
|
||||
|
@ -1579,6 +1580,19 @@ any '/api' => sub {
|
|||
}
|
||||
);
|
||||
}
|
||||
# Return just room config
|
||||
elsif ($req->{action} eq 'get_room_conf'){
|
||||
return $self->render(
|
||||
json => {
|
||||
owner_auth => ($room->{owner_password}) ? 'yes' : 'no',
|
||||
join_auth => ($room->{join_password}) ? 'yes' : 'no',
|
||||
locked => ($room->{locked}) ? 'yes' : 'no',
|
||||
ask_for_name => ($room->{ask_for_name}) ? 'yes' : 'no',
|
||||
notif => $self->get_notification($room->{name}),
|
||||
status => 'success'
|
||||
}
|
||||
);
|
||||
}
|
||||
# Return your role and various info about the room
|
||||
elsif ($req->{action} eq 'get_room_info'){
|
||||
my $peer_id = $req->{param}->{peer_id};
|
||||
|
|
Loading…
Reference in New Issue
Block a user