Allow localpart as username

If username is not a JID assume it is the local part and append an @
and the server domain.
This commit is contained in:
Martin Dosch 2020-06-06 12:06:55 +02:00
parent 76a747efb4
commit ce11b65376

View File

@ -136,6 +136,19 @@ func parseConfig(configPath string) (configuration, error) {
} }
file.Close() file.Close()
// Check if the username is a valid JID
output.username, err = MarshalJID(output.username)
if err != nil {
// Check whether only the local part was used by appending an @ and the
// server part.
output.username = output.username + "@" + output.jserver
// Check if the username is a valid JID now
output.username, err = MarshalJID(output.username)
if err != nil {
return output, errors.New("invalid username/JID: " + output.username)
}
}
return output, err return output, err
} }