From ad367e8edbd2582b552be32e543d6ad6f81b96c8 Mon Sep 17 00:00:00 2001 From: Anant Prakash Date: Thu, 15 Mar 2018 00:25:21 +0530 Subject: [PATCH] Make logic clearer, improve comments Signed-off-by: Anant Prakash --- .../matrix-org/dendrite/clientapi/auth/auth.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/clientapi/auth/auth.go b/src/github.com/matrix-org/dendrite/clientapi/auth/auth.go index 7f4e16a94..90fb72775 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/auth/auth.go +++ b/src/github.com/matrix-org/dendrite/clientapi/auth/auth.go @@ -63,7 +63,7 @@ func VerifyUserFromRequest( return dev.UserID, nil } - // Try to find Application Service user + // Try to find the Application Service user token, err := extractAccessToken(req) if err != nil { @@ -96,14 +96,8 @@ func VerifyUserFromRequest( // Verify that the user is registered account, accountErr := accountDB.GetAccountByLocalpart(req.Context(), localpart) - if accountErr != nil { - return "", &util.JSONResponse{ - Code: http.StatusForbidden, - JSON: jsonerror.Forbidden("Application service has not registered this user"), - } - } - - if account.AppServiceID == appService.ID { + // Verify that account exists & appServiceID matches + if accountErr == nil && account.AppServiceID == appService.ID { return userID, nil }