From cc58fd20ca2dd52a8c5761358137ee645d1716d1 Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Thu, 23 Nov 2023 16:04:56 +0530 Subject: [PATCH] refactor(oauth): simplify scopes check with the usage of `all()` Signed-off-by: Akhil Narang --- frappe/oauth.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frappe/oauth.py b/frappe/oauth.py index 78a70a2c1e..ebd6b91ae7 100644 --- a/frappe/oauth.py +++ b/frappe/oauth.py @@ -250,10 +250,7 @@ class OAuthWebRequestValidator(RequestValidator): client_scopes = frappe.db.get_value("OAuth Client", otoken.client, "scopes").split( get_url_delimiter() ) - are_scopes_valid = True - for scp in scopes: - are_scopes_valid = are_scopes_valid if scp in client_scopes else False - + are_scopes_valid = all(scope in client_scopes for scope in scopes) return is_token_valid and are_scopes_valid # Token refresh request