Clear accountUUID if it's still me after validation

This commit is contained in:
Benedikt Kulmann
2020-08-25 12:37:17 +02:00
parent 8b2c4f81cf
commit e1dc62c2e3
2 changed files with 11 additions and 1 deletions
+4
View File
@@ -328,6 +328,10 @@ func getValidatedAccountUUID(c context.Context, accountUUID string) string {
accountUUID = ownAccountUUID
}
}
if accountUUID == "me" {
// no matter what happens above, an accountUUID of `me` must not be passed on. Clear it instead.
accountUUID = ""
}
return accountUUID
}
+7 -1
View File
@@ -26,11 +26,17 @@ var (
expect: ctxWithUUID.Value(middleware.UUIDKey).(string),
},
{
name: "context without UUID; identifier = 'me'",
name: "context with empty UUID; identifier = 'me'",
ctx: ctxWithEmptyUUID,
accountUUID: "me",
expect: "",
},
{
name: "context without UUID; identifier = 'me'",
ctx: emptyCtx,
accountUUID: "me",
expect: "",
},
{
name: "context with UUID; identifier not 'me'",
ctx: ctxWithUUID,