mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
chasquid-util: Handle usernames without domain
Usernames must be of the form user@domain. When the domain is missing, this patch makes chasquid-util emit a friendly error (instead of crashing).
This commit is contained in:
@@ -82,6 +82,9 @@ func userDBForDomain(domain string) string {
|
|||||||
func userDBFromArgs(create bool) (string, string, *userdb.DB) {
|
func userDBFromArgs(create bool) (string, string, *userdb.DB) {
|
||||||
username := args["<username>"].(string)
|
username := args["<username>"].(string)
|
||||||
user, domain := envelope.Split(username)
|
user, domain := envelope.Split(username)
|
||||||
|
if domain == "" {
|
||||||
|
Fatalf("Domain missing, username should be of the form 'user@domain'")
|
||||||
|
}
|
||||||
|
|
||||||
db, err := userdb.Load(userDBForDomain(domain))
|
db, err := userdb.Load(userDBForDomain(domain))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user