Skip to content

Commit 792f35b

Browse files
committed
fix: fix minor bugs
1 parent 074a1a8 commit 792f35b

File tree

15 files changed

+115
-263
lines changed

15 files changed

+115
-263
lines changed

app/code/core/Mage/Oauth2/Block/Adminhtml/Client/Edit/Form.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function _prepareForm()
6565
'required' => true
6666
]);
6767

68-
$form->setAction($this->getUrl('*/*/save'));
68+
$form->setAction($this->getUrl('*/*/save', ['id' => $this->getModel()->getId()]));
6969
$form->setUseContainer(true);
7070
$this->setForm($form);
7171
return parent::_prepareForm();

app/code/core/Mage/Oauth2/Block/Adminhtml/Device.php

-28
This file was deleted.

app/code/core/Mage/Oauth2/Helper/Data.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ public function generateClientSecret($length = 40)
2222
* @return string The generated token
2323
* @throws Exception if unable to generate random bytes
2424
*/
25-
public function generateToken($clientId, $length = 40)
25+
public function generateToken($length = 40)
2626
{
27-
$randomPart = $this->generateRandomString($length - 8);
28-
$clientPart = substr(hash('crc32b', $clientId), 0, 8);
29-
return $randomPart . $clientPart;
27+
return $this->generateRandomString($length);
28+
;
3029
}
3130

3231
/**

app/code/core/Mage/Oauth2/Model/AccessToken.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
class Mage_Oauth2_Model_AccessToken extends Mage_Core_Model_Abstract
44
{
5-
const USER_TYPE_ADMIN = 'admin';
6-
const USER_TYPE_CUSTOMER = 'customer';
5+
public const USER_TYPE_ADMIN = 'admin';
6+
public const USER_TYPE_CUSTOMER = 'customer';
77

88
protected function _construct()
99
{

app/code/core/Mage/Oauth2/Model/Resource/AccessToken.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ protected function _construct()
1010
$this->_init('oauth2/access_token', 'access_token');
1111
$this->_isPkAutoIncrement = false;
1212
}
13-
}
13+
}

app/code/core/Mage/Oauth2/Model/Resource/AccessToken/Collection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ protected function _construct()
99
{
1010
$this->_init('oauth2/access_token');
1111
}
12-
}
12+
}

app/code/core/Mage/Oauth2/Model/Resource/AuthCode.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ protected function _construct()
1010
$this->_init('oauth2/auth_code', 'authorization_code');
1111
$this->_isPkAutoIncrement = false;
1212
}
13-
}
13+
}

app/code/core/Mage/Oauth2/Model/Resource/Client/Collection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ protected function _construct()
99
{
1010
$this->_init('oauth2/client');
1111
}
12-
}
12+
}

app/code/core/Mage/Oauth2/controllers/Adminhtml/Oauth2/ClientController.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ public function newAction()
7272
{
7373
$model = $this->_initClientModel();
7474
$formData = $this->_getFormData();
75-
75+
7676
if ($formData) {
7777
$model->addData($formData);
7878
} else {
7979
$model->setSecret(Mage::helper('oauth2')->generateClientSecret());
8080
}
81-
81+
8282
$this->_setFormData($formData ?: $model->getData());
8383
Mage::register('current_oauth2_client', $model);
8484

@@ -198,11 +198,11 @@ protected function _filter(array $data)
198198
foreach ($fieldsToRemove as $field) {
199199
unset($data[$field]);
200200
}
201-
201+
202202
if (isset($data['grant_types'])) {
203203
$data['grant_types'] = implode(',', $data['grant_types']);
204204
}
205-
205+
206206
return $data;
207207
}
208208

@@ -230,7 +230,7 @@ private function _loadModelById($model, $id)
230230
$this->_redirect('*/*/index');
231231
return false;
232232
}
233-
233+
234234
$model->load($id);
235235

236236
if (!$model->getId()) {
@@ -257,7 +257,7 @@ private function _handleSaveException($e, $data = null)
257257
$message = $e instanceof Mage_Core_Exception ? Mage::helper('core')->escapeHtml($e->getMessage()) : $this->__('An error occurred on saving client data.');
258258
$this->_getSession()->addError($message);
259259
$this->getRequest()->setParam('back', 'edit');
260-
260+
261261
if ($e instanceof Exception && !($e instanceof Mage_Core_Exception)) {
262262
Mage::logException($e);
263263
}
@@ -276,4 +276,4 @@ private function _redirectAfterSave($model)
276276
$this->_redirect('*/*/index');
277277
}
278278
}
279-
}
279+
}

app/code/core/Mage/Oauth2/controllers/Adminhtml/Oauth2/DeviceController.php

-131
This file was deleted.

app/code/core/Mage/Oauth2/controllers/AuthorizeController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected function _getCustomerId($params)
138138
*/
139139
protected function _authorizeClient($client, $customerId, $redirectUri)
140140
{
141-
$authorizationCode = $this->_getOauth2Helper()->generateToken($client->getId());
141+
$authorizationCode = $this->_getOauth2Helper()->generateToken();
142142
$model = Mage::getModel('oauth2/authCode');
143143
$model->setAuthorizationCode($authorizationCode)
144144
->setClientId($client->getId())

0 commit comments

Comments
 (0)