]> 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>
Wed, 15 Mar 2017 23:37:47 +0000 (01:37 +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 24dd2ccc6cd46de5f8804a5de0afc5a12b6cd2fa..0a3d4ee8f9a1bf156f87a2c0cffabb72249406f2 100644 (file)
@@ -562,12 +562,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;
        }