]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: oauth2 - Clarify token validation success/valid error handling
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 15 Mar 2017 23:35:38 +0000 (01:35 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 16 Mar 2017 17:46:45 +0000 (19:46 +0200)
result->error is NULL only if result->success && !result->valid.
Also !result->success is the more important error handling case.
Write out these cases explicitly so it's easier to understand.

src/auth/db-oauth2.c

index d3091851bad8c68461401ecf6483cc424fc058ed..9863b9a032c2704a4980c0e7d3ce1814858a689e 100644 (file)
@@ -548,12 +548,13 @@ db_oauth2_lookup_continue(struct oauth2_token_validation_result *result,
 {
        req->req = NULL;
 
-       if (!result->success || !result->valid) {
-               /* no point going forward */
-               enum passdb_result passdb_result = result->success ?
-                       PASSDB_RESULT_PASSWORD_MISMATCH :
-                       PASSDB_RESULT_INTERNAL_FAILURE;
-               db_oauth2_callback(req, passdb_result, result->error == NULL ? "Invalid token" : result->error);
+       if (!result->success) {
+               db_oauth2_callback(req, PASSDB_RESULT_INTERNAL_FAILURE,
+                                  result->error);
+               return;
+       } else if (!result->valid) {
+               db_oauth2_callback(req, PASSDB_RESULT_PASSWORD_MISMATCH,
+                                  "Invalid token");
                return;
        }