Add an auth form in the join template

Lets you authenticate as the room owner even if there's no join pasword
master
Daniel Berteaud 11 years ago
parent a5837dac98
commit 697b143cef
  1. 6
      lib/Vroom/I18N/en.pm
  2. 6
      lib/Vroom/I18N/fr.pm
  3. 6
      public/css/vroom.css
  4. 51
      public/js/vroom.js
  5. 26
      public/vroom.pl
  6. 24
      templates/default/join.html.ep

@ -67,6 +67,12 @@ our %Lexicon = (
"REMOVE_PASSWORD" => "Remove the password", "REMOVE_PASSWORD" => "Remove the password",
"PASSWORD_SET" => "Password updated", "PASSWORD_SET" => "Password updated",
"PASSWORD_REMOVED" => "Password removed", "PASSWORD_REMOVED" => "Password removed",
"AUTHENTICATE" => "Authentication",
"AUTH_TO_MANAGE_THE_ROOM" => "Authenticate to manage the room",
"OWNER_PASSWORD_MAKES_PERSISTENT" => "You can set a manager password. It will make this room persistent",
"OWNER_PASSWORD" => "Manager password",
"REMOVE_OWNER_PASSWORD" => "Remove the manager password. The room will become ephemeral",
"AUTH_SUCCESS" => "You are now authenticated",
"NOT_ALLOWED" => "You are not allowed to do this", "NOT_ALLOWED" => "You are not allowed to do this",
"WRONG_PASSWORD" => "Wrong password", "WRONG_PASSWORD" => "Wrong password",
"PASSWORD_REQUIRED" => "Password required", "PASSWORD_REQUIRED" => "Password required",

@ -73,6 +73,12 @@ our %Lexicon = (
"REMOVE_PASSWORD" => "Supprimer le mot de passe", "REMOVE_PASSWORD" => "Supprimer le mot de passe",
"PASSWORD_SET" => "Le mot de passe a été mis à jour", "PASSWORD_SET" => "Le mot de passe a été mis à jour",
"PASSWORD_REMOVED" => "Le mot de passe a été supprimé", "PASSWORD_REMOVED" => "Le mot de passe a été supprimé",
"AUTHENTICATE" => "Authentification",
"AUTH_TO_MANAGE_THE_ROOM" => "Authentifiez-vous pour gérer le salon",
"OWNER_PASSWORD_MAKES_PERSISTENT" => "Vous pouvez ajouter un mot de passe de gestionnaire. Ceci rendra le salon persistant",
"OWNER_PASSWORD" => "Mot de passe du gestionnaire",
"REMOVE_OWNER_PASSWORD" => "Supprimer le mot de passe du gestionnaire. Le salon redeviendra éphémère",
"AUTH_SUCCESS" => "Vous êtes maintenant authentifié",
"NOT_ALLOWED" => "Vous n'êtes pas autorisé à faire ceci", "NOT_ALLOWED" => "Vous n'êtes pas autorisé à faire ceci",
"WRONG_PASSWORD" => "Mauvais mot de passe", "WRONG_PASSWORD" => "Mauvais mot de passe",
"PASSWORD_REQUIRED" => "Mot de passe requis", "PASSWORD_REQUIRED" => "Mot de passe requis",

@ -79,9 +79,15 @@
#confMenu { #confMenu {
min-width: 400px; min-width: 400px;
} }
#authMenu {
min-width: 400px;
}
.ownerEl { .ownerEl {
display: none; display: none;
} }
.unauthEl{
display: none;
}
#chatBox { #chatBox {
max-height:300px; max-height:300px;
resize:none; resize:none;

@ -122,13 +122,17 @@ function initVroom(room) {
$.notify(locale.ERROR_OCCURED, 'error'); $.notify(locale.ERROR_OCCURED, 'error');
}, },
success: function(data) { success: function(data) {
peers.local.role = data.msg; peers.local.role = data.role;
// Enable owner reserved menu // Enable owner reserved menu
if (data.msg == 'owner'){ if (data.role == 'owner'){
$('.unauthEl').hide(500);
$('.ownerEl').show(500); $('.ownerEl').show(500);
} }
else{ else{
$('.ownerEl').hide(500); $('.ownerEl').hide(500);
if (data.auth == 'yes'){
$('.unauthEl').show(500);
}
} }
} }
}); });
@ -455,11 +459,17 @@ function initVroom(room) {
if (peers.local.role == 'owner'){ if (peers.local.role == 'owner'){
$.notify(sprintf(locale.OWNER_PASSWORD_CHANGED_BY_s, stringEscape(peers[data.id].displayName)), 'warn'); $.notify(sprintf(locale.OWNER_PASSWORD_CHANGED_BY_s, stringEscape(peers[data.id].displayName)), 'warn');
} }
else{
updateRole();
}
}); });
webrtc.on('owner_password_removed', function(data){ webrtc.on('owner_password_removed', function(data){
if (peers.local.role == 'owner'){ if (peers.local.role == 'owner'){
$.notify(sprintf(locale.OWNER_PASSWORD_REMOVED_BY_s, stringEscape(peers[data.id].displayName)), 'warn'); $.notify(sprintf(locale.OWNER_PASSWORD_REMOVED_BY_s, stringEscape(peers[data.id].displayName)), 'warn');
} }
else{
updateRole();
}
}); });
// Handle the readyToCall event: join the room // Handle the readyToCall event: join the room
@ -624,6 +634,43 @@ function initVroom(room) {
} }
}); });
// Handle auth
$('#authPass').on('input', function() {
if ($('#authPass').val() == ''){
$('#authPassButton').addClass('disabled');
}
else{
$('#authPassButton').removeClass('disabled');
}
});
$('#authForm').submit(function(event) {
event.preventDefault();
var pass = $('#authPass').val();
$.ajax({
data: {
action: 'authenticate',
password: pass,
room: roomName
},
error: function(data) {
var msg = locale.ERROR_OCCURED;
$.notify(msg, 'error');
},
success: function(data) {
$('#authPass').val('');
if (data.status == 'success'){
updateRole();
$.notify(data.msg, 'success');
}
else{
$.notify(data.msg, 'error');
}
// Close the auth menu
$('#authMenu').dropdown('toggle');
}
});
});
$('#joinPass').on('input', function() { $('#joinPass').on('input', function() {
if ($('#joinPass').val() == ''){ if ($('#joinPass').val() == ''){
$('#setJoinPassButton').addClass('disabled'); $('#setJoinPassButton').addClass('disabled');

@ -551,10 +551,34 @@ post '/action' => sub {
); );
} }
} }
elsif ($action eq 'authenticate'){
my $pass = $self->param('password');
my $res = undef;
my $msg = 'ERROR_OCCURED';
my $status = 'error';
if ($data->{owner_password} && Crypt::SaltedHash->validate($data->{owner_password}, $pass)){
$self->session($room, {role => 'owner'});
$msg = 'AUTH_SUCCESS';
$status = 'success';
}
elsif ($data->{owner_password}){
$msg = 'WRONG_PASSWORD';
}
else{
$msg = 'NOT_ALLOWED';
}
return $self->render(
json => {
msg => $self->l($msg),
status => $status
},
);
}
elsif ($action eq 'getRole'){ elsif ($action eq 'getRole'){
return $self->render( return $self->render(
json => { json => {
msg => $self->session($room)->{role}, role => $self->session($room)->{role},
auth => ($data->{owner_password}) ? 'yes' : 'no',
status => 'success' status => 'success'
}, },
); );

@ -130,6 +130,30 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="btn-group navbar-form navbar-left">
<button class="btn btn-default dropdown-toggle help unauthEl" type="button" id="authMenuButton" data-toggle="dropdown" data-toggle="tooltip" data-placement="bottom" title="<%=l 'AUTHENTICATE' %>">
<span class="glyphicon glyphicon-log-in"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="authMenuButton" id="authMenu">
<li>
<form class="navbar-form" id="authForm">
<center>
<p><%=l 'AUTH_TO_MANAGE_THE_ROOM' %></p>
</center>
<div class="input-group">
<input type="password" id="authPass" class="form-control help" placeholder="<%=l 'PASSWORD' %>" data-toggle="tooltip" data-placement="bottom" title="<%=l 'AUTHENTICATE' %>"/>
<span class="input-group-btn">
<button id="authPassButton" type="submit" class="btn btn-default help disabled" data-toggle="tooltip" data-placement="bottom" title="<%=l 'AUTHENTICATE' %>">
<span class="glyphicon glyphicon-ok"
</span>
</button>
</span>
</div>
</form>
</li>
</ul>
</div>
<div class="btn-group navbar-form navbar-right" data-toggle="buttons" > <div class="btn-group navbar-form navbar-right" data-toggle="buttons" >
<button class="btn btn-default help" id="logoutButton" data-toggle="tooltip" data-placement="bottom" title="<%=l 'LOGOUT' %>"> <button class="btn btn-default help" id="logoutButton" data-toggle="tooltip" data-placement="bottom" title="<%=l 'LOGOUT' %>">
<span class="glyphicon glyphicon-log-out"> <span class="glyphicon glyphicon-log-out">

Loading…
Cancel
Save