mirror of
https://github.com/jech/galene.git
synced 2024-11-09 02:05:59 +01:00
Report username errors to client.
We now report ErrUsernameRequired and ErrDuplicateUsername errors by setting the "error" field of messages.
This commit is contained in:
parent
8c1510023f
commit
4c9e00d874
1 changed files with 12 additions and 1 deletions
|
@ -1434,8 +1434,14 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
|||
time.Sleep(200 * time.Millisecond)
|
||||
} else if err == group.ErrAnonymousNotAuthorised {
|
||||
s = "please choose a username"
|
||||
} else if err, ok := err.(group.UserError); ok {
|
||||
} else if _, ok := err.(group.UserError); ok {
|
||||
s = err.Error()
|
||||
} else if err == token.ErrUsernameRequired {
|
||||
s = err.Error()
|
||||
e = "need-username"
|
||||
} else if err == group.ErrDuplicateUsername {
|
||||
s = err.Error()
|
||||
e = "duplicate-username"
|
||||
} else {
|
||||
s = "internal server error"
|
||||
log.Printf("Join group: %v", err)
|
||||
|
@ -1738,6 +1744,11 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
|||
return terror("error", "token doesn't expire")
|
||||
}
|
||||
|
||||
if tok.Username != nil &&
|
||||
c.group.UserExists(*tok.Username) {
|
||||
return terror("error", "that username is taken")
|
||||
}
|
||||
|
||||
for _, p := range tok.Permissions {
|
||||
if !member(p, c.permissions) {
|
||||
return terror(
|
||||
|
|
Loading…
Reference in a new issue