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)
|
||||
}
|
||||
case "op", "unop", "present", "unpresent":
|
||||
if !c.permissions.Admin {
|
||||
if !c.permissions.Op {
|
||||
c.error(userError("not authorised"))
|
||||
return nil
|
||||
}
|
||||
|
@ -803,7 +803,7 @@ func handleClientMessage(c *client, m clientMessage) error {
|
|||
return c.error(err)
|
||||
}
|
||||
case "kick":
|
||||
if !c.permissions.Admin {
|
||||
if !c.permissions.Op {
|
||||
c.error(userError("not authorised"))
|
||||
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
|
||||
g.mu.Lock()
|
||||
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 {
|
||||
return nil, nil, userError("too many users")
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ type groupDescription struct {
|
|||
Public bool `json:"public,omitempty"`
|
||||
MaxClients int `json:"max-clients,omitempty"`
|
||||
AllowAnonymous bool `json:"allow-anonymous,omitempty"`
|
||||
Admin []groupUser `json:"admin,omitempty"`
|
||||
Op []groupUser `json:"op,omitempty"`
|
||||
Presenter []groupUser `json:"presenter,omitempty"`
|
||||
Other []groupUser `json:"other,omitempty"`
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ func getDescription(name string) (*groupDescription, error) {
|
|||
}
|
||||
|
||||
type userPermission struct {
|
||||
Admin bool `json:"admin,omitempty"`
|
||||
Op bool `json:"op,omitempty"`
|
||||
Present bool `json:"present,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -379,9 +379,9 @@ func getPermission(desc *groupDescription, user, pass string) (userPermission, e
|
|||
if !desc.AllowAnonymous && user == "" {
|
||||
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 {
|
||||
p.Admin = true
|
||||
p.Op = true
|
||||
p.Present = true
|
||||
return p, nil
|
||||
}
|
||||
|
@ -414,9 +414,9 @@ func setPermission(g *group, id string, perm string) error {
|
|||
|
||||
switch perm {
|
||||
case "op":
|
||||
c.permissions.Admin = true
|
||||
c.permissions.Op = true
|
||||
case "unop":
|
||||
c.permissions.Admin = false
|
||||
c.permissions.Op = false
|
||||
case "present":
|
||||
c.permissions.Present = true
|
||||
case "unpresent":
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<div id="header">
|
||||
<div id="statdiv">
|
||||
<span id="statspan"></span>
|
||||
<span id="userspan"></span>
|
||||
<form id="userform" class="userform">
|
||||
<label for="username">Username:</label>
|
||||
<input id="username" type="text" name="username"
|
||||
|
|
|
@ -83,6 +83,7 @@ function setConnected(connected) {
|
|||
userform.classList.add('userform-invisible');
|
||||
userform.classList.remove('userform');
|
||||
disconnectbutton.classList.remove('disconnect-invisible');
|
||||
displayUsername();
|
||||
} else {
|
||||
let userpass = getUserPass();
|
||||
document.getElementById('username').value =
|
||||
|
@ -96,6 +97,7 @@ function setConnected(connected) {
|
|||
userform.classList.remove('userform-invisible');
|
||||
disconnectbutton.classList.add('disconnect-invisible');
|
||||
permissions={};
|
||||
clearUsername(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,10 +520,29 @@ function gotUser(id, name, del) {
|
|||
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) {
|
||||
permissions = perm;
|
||||
document.getElementById('presenterbox').disabled = !perm.present;
|
||||
document.getElementById('sharebox').disabled = !perm.present;
|
||||
displayUsername();
|
||||
}
|
||||
|
||||
const urlRegexp = /https?:\/\/[-a-zA-Z0-9@:%/._\+~#=?]+[-a-zA-Z0-9@:%/_\+~#=]/g;
|
||||
|
@ -647,8 +668,8 @@ function handleInput() {
|
|||
case '/kick':
|
||||
case '/present':
|
||||
case '/unpresent':
|
||||
if(!permissions.admin) {
|
||||
displayError("You're not an administrator");
|
||||
if(!permissions.op) {
|
||||
displayError("You're not an operator");
|
||||
return;
|
||||
}
|
||||
let id;
|
||||
|
|
Loading…
Reference in a new issue