usernames: report reserved names as taken in the check paths too
account.checkUsername / channels.checkUsername / bots.checkUsername said a reserved name was available and only updateUsername rejected it. Add the blocklist check to peerUsernameAvailable (covers account + channel, both backends) and to bots.Service.CheckUsername, so the client shows "username is taken" immediately.
This commit is contained in:
parent
60537342d3
commit
f1c24e483c
7 changed files with 79 additions and 5 deletions
|
|
@ -81,6 +81,11 @@ func usernameReservedTx(ctx context.Context, db sqlcgen.DBTX, usernameLower stri
|
|||
}
|
||||
|
||||
func peerUsernameAvailable(ctx context.Context, db sqlcgen.DBTX, usernameLower, peerType string, peerID int64) (bool, error) {
|
||||
if reserved, err := usernameReservedTx(ctx, db, usernameLower); err != nil {
|
||||
return false, err
|
||||
} else if reserved {
|
||||
return false, nil
|
||||
}
|
||||
owner, found, err := getPeerUsernameOwner(ctx, db, usernameLower, false)
|
||||
if err != nil || !found {
|
||||
return !found, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue