File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,9 @@ public function retrieveByCredentials(array $credentials)
5454 {
5555 if ($ this ->isSignedChallenge ($ credentials )) {
5656 try {
57- $ webauthnKey = (Webauthn::model ())::where ([
58- 'credentialId ' => Base64UrlSafe::encode (Base64::decode ($ credentials ['id ' ])),
59- ]) ->firstOrFail ();
57+ $ webauthnKey = (Webauthn::model ())::where (' credentialId ' , Base64UrlSafe:: encode (Base64:: decode ( $ credentials [ ' id ' ])))
58+ -> orWhere ( 'credentialId ' , Base64UrlSafe::encodeUnpadded (Base64::decode ($ credentials ['id ' ])))
59+ ->firstOrFail ();
6060
6161 return $ this ->retrieveById ($ webauthnKey ->user_id );
6262 } catch (ModelNotFoundException $ e ) {
Original file line number Diff line number Diff line change @@ -111,12 +111,16 @@ public function getRegisteredKeys(User $user): array
111111 */
112112 private function model (string $ credentialId ): WebauthnKey
113113 {
114- return (Webauthn::model ())::where (array_filter (
115- [
116- 'user_id ' => $ this ->guard ()->guest () ? null : $ this ->guard ()->id (),
117- 'credentialId ' => Base64UrlSafe::encode ($ credentialId ),
118- ]
119- ))->firstOrFail ();
114+ return (Webauthn::model ())::where (function ($ query ) {
115+ if ($ this ->guard ()->check ()) {
116+ $ query ->where ('user_id ' , $ this ->guard ()->id ());
117+ }
118+ })
119+ ->where (function ($ query ) use ($ credentialId ) {
120+ $ query ->where ('credentialId ' , Base64UrlSafe::encode ($ credentialId ))
121+ ->orWhere ('credentialId ' , Base64UrlSafe::encodeUnpadded ($ credentialId ));
122+ })
123+ ->firstOrFail ();
120124 }
121125
122126 /**
You can’t perform that action at this time.
0 commit comments