File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
app/code/Magento/Integration/Model Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 2020use Magento \Integration \Helper \Oauth \Data as OauthHelper ;
2121
2222/**
23+ * Reads user token data
24+ *
2325 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2426 */
2527class Reader implements UserTokenReaderInterface
@@ -112,6 +114,7 @@ private function getTokenModel(string $token): Token
112114 * Validate the given user type
113115 *
114116 * @param int $userType
117+ * @throws UserTokenException
115118 */
116119 private function validateUserType (int $ userType ): void
117120 {
Original file line number Diff line number Diff line change @@ -34,10 +34,30 @@ public function __construct(DtUtil $datetimeUtil)
3434 */
3535 public function validate (UserToken $ token ): void
3636 {
37- if ($ token ->getUserContext ()->getUserType () !== UserContextInterface::USER_TYPE_INTEGRATION
38- && $ token ->getData ()->getExpires ()->getTimestamp () <= $ this ->datetimeUtil ->gmtTimestamp ()
39- ) {
37+ if (!$ this ->isIntegrationToken ($ token ) && $ this ->isTokenExpired ($ token )) {
4038 throw new AuthorizationException (__ ('Consumer key has expired ' ));
4139 }
4240 }
41+
42+ /**
43+ * Check if a token is expired
44+ *
45+ * @param UserToken $token
46+ * @return bool
47+ */
48+ private function isTokenExpired (UserToken $ token ): bool
49+ {
50+ return $ token ->getData ()->getExpires ()->getTimestamp () <= $ this ->datetimeUtil ->gmtTimestamp ();
51+ }
52+
53+ /**
54+ * Check if a token is an integration token
55+ *
56+ * @param UserToken $token
57+ * @return bool
58+ */
59+ private function isIntegrationToken (UserToken $ token ): bool
60+ {
61+ return $ token ->getUserContext ()->getUserType () === UserContextInterface::USER_TYPE_INTEGRATION ;
62+ }
4363}
You can’t perform that action at this time.
0 commit comments