mirror of
https://github.com/jech/galene.git
synced 2024-11-09 02:05:59 +01:00
Use a dedicated error value for anonymous users.
This commit is contained in:
parent
d33e4dea9b
commit
f683675ab4
2 changed files with 4 additions and 1 deletions
|
@ -22,6 +22,7 @@ var UseMDNS bool
|
|||
var UDPMin, UDPMax uint16
|
||||
|
||||
var ErrNotAuthorised = errors.New("not authorised")
|
||||
var ErrAnonymousNotAuthorised = errors.New("anonymous users not authorised in this group")
|
||||
|
||||
type UserError string
|
||||
|
||||
|
@ -966,7 +967,7 @@ func GetDescription(name string) (*Description, error) {
|
|||
func (desc *Description) GetPermission(group string, c Challengeable) (ClientPermissions, error) {
|
||||
var p ClientPermissions
|
||||
if !desc.AllowAnonymous && c.Username() == "" {
|
||||
return p, UserError("anonymous users not allowed in this group, please choose a username")
|
||||
return p, ErrAnonymousNotAuthorised
|
||||
}
|
||||
if found, good := matchClient(group, c, desc.Op); found {
|
||||
if good {
|
||||
|
|
|
@ -1351,6 +1351,8 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
|||
} else if err == group.ErrNotAuthorised {
|
||||
s = "not authorised"
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
} else if err == group.ErrAnonymousNotAuthorised {
|
||||
s = "please choose a username"
|
||||
} else if e, ok := err.(group.UserError); ok {
|
||||
s = string(e)
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue