Allow AS to deactivate it's own users (#30)

This commit is contained in:
PiotrKozimor 2022-08-26 14:41:09 +02:00 committed by GitHub
parent d15a4e4a61
commit 0782819d26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,13 +27,17 @@ func Deactivate(
JSON: jsonerror.BadJSON("The request body could not be read: " + err.Error()), JSON: jsonerror.BadJSON("The request body could not be read: " + err.Error()),
} }
} }
var userId string
login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI) if deviceAPI.AccountType != api.AccountTypeAppService {
if errRes != nil { login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI)
return *errRes if errRes != nil {
return *errRes
}
userId = login.Username()
} else {
userId = deviceAPI.UserID
} }
localpart, _, err := gomatrixserverlib.SplitID('@', userId)
localpart, _, err := gomatrixserverlib.SplitID('@', login.Username())
if err != nil { if err != nil {
util.GetLogger(req.Context()).WithError(err).Error("gomatrixserverlib.SplitID failed") util.GetLogger(req.Context()).WithError(err).Error("gomatrixserverlib.SplitID failed")
return jsonerror.InternalServerError() return jsonerror.InternalServerError()