@@ -42,12 +42,12 @@ public function __construct(
42
42
DeviceCodeManagerInterface $ deviceCodeManager ,
43
43
ClientManagerInterface $ clientManager ,
44
44
ScopeConverterInterface $ scopeConverter ,
45
- ClientRepositoryInterface $ clientRepository
45
+ ClientRepositoryInterface $ clientRepository,
46
46
) {
47
47
$ this ->deviceCodeManager = $ deviceCodeManager ;
48
- $ this ->clientManager = $ clientManager ;
49
- $ this ->scopeConverter = $ scopeConverter ;
50
- $ this ->clientRepository = $ clientRepository ;
48
+ $ this ->clientManager = $ clientManager ;
49
+ $ this ->scopeConverter = $ scopeConverter ;
50
+ $ this ->clientRepository = $ clientRepository ;
51
51
}
52
52
53
53
public function getNewDeviceCode (): DeviceCodeEntityInterface
@@ -76,15 +76,15 @@ public function approveDeviceCode(string $userCode, string $userId): void
76
76
{
77
77
$ deviceCode = $ this ->deviceCodeManager ->findByUserCode ($ userCode );
78
78
79
- if ($ deviceCode instanceof DeviceCodeInterface === false ) {
79
+ if (false === $ deviceCode instanceof DeviceCodeInterface) {
80
80
throw OAuthServerException::invalidRequest ('device_code ' , 'Device code does not exist ' );
81
81
}
82
82
83
83
if ($ deviceCode ->isRevoked ()) {
84
84
throw OAuthServerException::invalidRequest ('device_code ' , 'Device code has been revoked ' );
85
85
}
86
86
87
- if ($ userId === '' ) {
87
+ if ('' === $ userId ) {
88
88
throw OAuthServerException::invalidRequest ('user_id ' , 'User ID is required ' );
89
89
}
90
90
@@ -134,15 +134,18 @@ private function buildDeviceCodeEntity(DeviceCodeInterface $deviceCode): DeviceC
134
134
$ deviceCodeEntity = new DeviceCodeEntity ();
135
135
$ deviceCodeEntity ->setIdentifier ($ deviceCode ->getIdentifier ());
136
136
$ deviceCodeEntity ->setExpiryDateTime ($ deviceCode ->getExpiry ());
137
- $ deviceCodeEntity ->setClient (
138
- $ this ->clientRepository ->buildClientEntity ($ deviceCode ->getClient ())
139
- );
137
+
138
+ $ client = $ this ->clientRepository ->getClientEntity ($ deviceCode ->getClient ()->getIdentifier ());
139
+ if ($ client ) {
140
+ $ deviceCodeEntity ->setClient (
141
+ $ client
142
+ );
143
+ }
140
144
if ($ deviceCode ->getUserIdentifier ()) {
141
145
$ deviceCodeEntity ->setUserIdentifier ($ deviceCode ->getUserIdentifier ());
142
146
}
143
147
$ deviceCodeEntity ->setUserCode ($ deviceCode ->getUserCode ());
144
148
$ deviceCodeEntity ->setUserApproved ($ deviceCode ->getUserApproved ());
145
- $ deviceCodeEntity ->setVerificationUriCompleteInAuthResponse ($ deviceCode ->getIncludeVerificationUriComplete ());
146
149
$ deviceCodeEntity ->setVerificationUri ($ deviceCode ->getVerificationUri ());
147
150
if ($ deviceCode ->getLastPolledAt ()) {
148
151
$ deviceCodeEntity ->setLastPolledAt ($ deviceCode ->getLastPolledAt ());
@@ -156,7 +159,6 @@ private function buildDeviceCodeEntity(DeviceCodeInterface $deviceCode): DeviceC
156
159
return $ deviceCodeEntity ;
157
160
}
158
161
159
-
160
162
private function buildDeviceCodeModel (DeviceCodeEntityInterface $ deviceCodeEntity ): DeviceCodeModel
161
163
{
162
164
/** @var AbstractClient $client */
@@ -172,11 +174,9 @@ private function buildDeviceCodeModel(DeviceCodeEntityInterface $deviceCodeEntit
172
174
$ this ->scopeConverter ->toDomainArray (array_values ($ deviceCodeEntity ->getScopes ())),
173
175
$ deviceCodeEntity ->getUserCode (),
174
176
$ deviceCodeEntity ->getUserApproved (),
175
- $ deviceCodeEntity ->getVerificationUriCompleteInAuthResponse (),
176
177
$ deviceCodeEntity ->getVerificationUri (),
177
178
$ deviceCodeEntity ->getLastPolledAt (),
178
179
$ deviceCodeEntity ->getInterval ()
179
180
);
180
181
}
181
-
182
182
}
0 commit comments