From: Timo Sirainen Date: Wed, 15 Mar 2017 23:35:38 +0000 (+0200) Subject: auth: oauth2 - Clarify token validation success/valid error handling X-Git-Tag: 2.3.0.rc1~1948 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e252a81ca2dc3eb8d2af986229a3a40ff26c5ce8;p=thirdparty%2Fdovecot%2Fcore.git auth: oauth2 - Clarify token validation success/valid error handling 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. --- diff --git a/src/auth/db-oauth2.c b/src/auth/db-oauth2.c index 24dd2ccc6c..0a3d4ee8f9 100644 --- a/src/auth/db-oauth2.c +++ b/src/auth/db-oauth2.c @@ -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; }