mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Display username, rename admin to op.
This commit is contained in:
parent
a45914fec4
commit
8bfdc2b040
4 changed files with 33 additions and 11 deletions
|
@ -794,7 +794,7 @@ func handleClientMessage(c *client, m clientMessage) error {
|
||||||
cc.write(m)
|
cc.write(m)
|
||||||
}
|
}
|
||||||
case "op", "unop", "present", "unpresent":
|
case "op", "unop", "present", "unpresent":
|
||||||
if !c.permissions.Admin {
|
if !c.permissions.Op {
|
||||||
c.error(userError("not authorised"))
|
c.error(userError("not authorised"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -803,7 +803,7 @@ func handleClientMessage(c *client, m clientMessage) error {
|
||||||
return c.error(err)
|
return c.error(err)
|
||||||
}
|
}
|
||||||
case "kick":
|
case "kick":
|
||||||
if !c.permissions.Admin {
|
if !c.permissions.Op {
|
||||||
c.error(userError("not authorised"))
|
c.error(userError("not authorised"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
14
group.go
14
group.go
|
@ -196,7 +196,7 @@ func addClient(name string, client *client, user, pass string) (*group, []userid
|
||||||
var users []userid
|
var users []userid
|
||||||
g.mu.Lock()
|
g.mu.Lock()
|
||||||
defer g.mu.Unlock()
|
defer g.mu.Unlock()
|
||||||
if !perms.Admin && g.description.MaxClients > 0 {
|
if !perms.Op && g.description.MaxClients > 0 {
|
||||||
if len(g.clients) >= g.description.MaxClients {
|
if len(g.clients) >= g.description.MaxClients {
|
||||||
return nil, nil, userError("too many users")
|
return nil, nil, userError("too many users")
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ type groupDescription struct {
|
||||||
Public bool `json:"public,omitempty"`
|
Public bool `json:"public,omitempty"`
|
||||||
MaxClients int `json:"max-clients,omitempty"`
|
MaxClients int `json:"max-clients,omitempty"`
|
||||||
AllowAnonymous bool `json:"allow-anonymous,omitempty"`
|
AllowAnonymous bool `json:"allow-anonymous,omitempty"`
|
||||||
Admin []groupUser `json:"admin,omitempty"`
|
Op []groupUser `json:"op,omitempty"`
|
||||||
Presenter []groupUser `json:"presenter,omitempty"`
|
Presenter []groupUser `json:"presenter,omitempty"`
|
||||||
Other []groupUser `json:"other,omitempty"`
|
Other []groupUser `json:"other,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -370,7 +370,7 @@ func getDescription(name string) (*groupDescription, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type userPermission struct {
|
type userPermission struct {
|
||||||
Admin bool `json:"admin,omitempty"`
|
Op bool `json:"op,omitempty"`
|
||||||
Present bool `json:"present,omitempty"`
|
Present bool `json:"present,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,9 +379,9 @@ func getPermission(desc *groupDescription, user, pass string) (userPermission, e
|
||||||
if !desc.AllowAnonymous && user == "" {
|
if !desc.AllowAnonymous && user == "" {
|
||||||
return p, userError("anonymous users not allowed in this group, please choose a username")
|
return p, userError("anonymous users not allowed in this group, please choose a username")
|
||||||
}
|
}
|
||||||
if found, good := matchUser(user, pass, desc.Admin); found {
|
if found, good := matchUser(user, pass, desc.Op); found {
|
||||||
if good {
|
if good {
|
||||||
p.Admin = true
|
p.Op = true
|
||||||
p.Present = true
|
p.Present = true
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
@ -414,9 +414,9 @@ func setPermission(g *group, id string, perm string) error {
|
||||||
|
|
||||||
switch perm {
|
switch perm {
|
||||||
case "op":
|
case "op":
|
||||||
c.permissions.Admin = true
|
c.permissions.Op = true
|
||||||
case "unop":
|
case "unop":
|
||||||
c.permissions.Admin = false
|
c.permissions.Op = false
|
||||||
case "present":
|
case "present":
|
||||||
c.permissions.Present = true
|
c.permissions.Present = true
|
||||||
case "unpresent":
|
case "unpresent":
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<div id="statdiv">
|
<div id="statdiv">
|
||||||
<span id="statspan"></span>
|
<span id="statspan"></span>
|
||||||
|
<span id="userspan"></span>
|
||||||
<form id="userform" class="userform">
|
<form id="userform" class="userform">
|
||||||
<label for="username">Username:</label>
|
<label for="username">Username:</label>
|
||||||
<input id="username" type="text" name="username"
|
<input id="username" type="text" name="username"
|
||||||
|
|
|
@ -83,6 +83,7 @@ function setConnected(connected) {
|
||||||
userform.classList.add('userform-invisible');
|
userform.classList.add('userform-invisible');
|
||||||
userform.classList.remove('userform');
|
userform.classList.remove('userform');
|
||||||
disconnectbutton.classList.remove('disconnect-invisible');
|
disconnectbutton.classList.remove('disconnect-invisible');
|
||||||
|
displayUsername();
|
||||||
} else {
|
} else {
|
||||||
let userpass = getUserPass();
|
let userpass = getUserPass();
|
||||||
document.getElementById('username').value =
|
document.getElementById('username').value =
|
||||||
|
@ -96,6 +97,7 @@ function setConnected(connected) {
|
||||||
userform.classList.remove('userform-invisible');
|
userform.classList.remove('userform-invisible');
|
||||||
disconnectbutton.classList.add('disconnect-invisible');
|
disconnectbutton.classList.add('disconnect-invisible');
|
||||||
permissions={};
|
permissions={};
|
||||||
|
clearUsername(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,10 +520,29 @@ function gotUser(id, name, del) {
|
||||||
addUser(id, name);
|
addUser(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayUsername() {
|
||||||
|
let userpass = getUserPass();
|
||||||
|
let text = '';
|
||||||
|
if(userpass && userpass.username)
|
||||||
|
text = 'as ' + userpass.username;
|
||||||
|
if(permissions.op && permissions.present)
|
||||||
|
text = text + ' (op, presenter)';
|
||||||
|
else if(permissions.op)
|
||||||
|
text = text + ' (op)';
|
||||||
|
else if(permissions.present)
|
||||||
|
text = text + ' (presenter)';
|
||||||
|
document.getElementById('userspan').textContent = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearUsername() {
|
||||||
|
document.getElementById('userspan').textContent = '';
|
||||||
|
}
|
||||||
|
|
||||||
function gotPermissions(perm) {
|
function gotPermissions(perm) {
|
||||||
permissions = perm;
|
permissions = perm;
|
||||||
document.getElementById('presenterbox').disabled = !perm.present;
|
document.getElementById('presenterbox').disabled = !perm.present;
|
||||||
document.getElementById('sharebox').disabled = !perm.present;
|
document.getElementById('sharebox').disabled = !perm.present;
|
||||||
|
displayUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
const urlRegexp = /https?:\/\/[-a-zA-Z0-9@:%/._\+~#=?]+[-a-zA-Z0-9@:%/_\+~#=]/g;
|
const urlRegexp = /https?:\/\/[-a-zA-Z0-9@:%/._\+~#=?]+[-a-zA-Z0-9@:%/_\+~#=]/g;
|
||||||
|
@ -647,8 +668,8 @@ function handleInput() {
|
||||||
case '/kick':
|
case '/kick':
|
||||||
case '/present':
|
case '/present':
|
||||||
case '/unpresent':
|
case '/unpresent':
|
||||||
if(!permissions.admin) {
|
if(!permissions.op) {
|
||||||
displayError("You're not an administrator");
|
displayError("You're not an operator");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let id;
|
let id;
|
||||||
|
|
Loading…
Reference in a new issue