Skip to content

Commit 52bebd0

Browse files
committed
Merge pull request #79 from zendesk/jose/sso-redirect
Admin SSO fix for Magento 1.9
2 parents 234e13d + 52eaf7d commit 52bebd0

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/app/code/community/Zendesk/Zendesk/Model/Observer.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,18 @@ public function createAccount($data)
224224
Mage::getModel('zendesk/api_users')->create($data);
225225
}
226226

227+
public function checkSsoRedirect($user)
228+
{
229+
if (
230+
Mage::helper('zendesk')->isSSOAdminUsersEnabled() &&
231+
Mage::app()->getRequest()->getControllerName() === 'zendesk' &&
232+
Mage::app()->getRequest()->getActionName() === 'authenticate'
233+
) {
234+
Mage::app()->getResponse()
235+
->setRedirect(Mage::helper('adminhtml')->getUrl('*/zendesk/authenticate'))
236+
->sendHeaders()
237+
->sendResponse();
238+
exit();
239+
}
240+
}
227241
}

src/app/code/community/Zendesk/Zendesk/controllers/Adminhtml/ZendeskController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class Zendesk_Zendesk_Adminhtml_ZendeskController extends Mage_Adminhtml_Controller_Action
2121
{
22-
protected $_publicActions = array('redirect', 'authenticate');
22+
protected $_publicActions = array('redirect', 'logout');
2323

2424
public function indexAction()
2525
{
@@ -147,12 +147,13 @@ public function logoutAction()
147147
{
148148
// Admin sessions do not currently have an explicit "logout" method (unlike customer sessions) so do this
149149
// manually with the session object
150+
150151
$adminSession = Mage::getSingleton('admin/session');
151152
$adminSession->unsetAll();
152153
$adminSession->getCookie()->delete($adminSession->getSessionName());
153154
$adminSession->addSuccess(Mage::helper('adminhtml')->__('You have logged out.'));
154155

155-
$this->_redirect('adminhtml/zendesk/*');
156+
$this->_redirect('adminhtml/zendesk/authenticate');
156157
}
157158

158159
public function createAction()

src/app/code/community/Zendesk/Zendesk/etc/config.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
</connection>
6262
</zendesk_read>
6363
</resources>
64+
<events>
65+
<admin_session_user_login_success>
66+
<observers>
67+
<zendesk>
68+
<class>zendesk/observer</class>
69+
<method>checkSsoRedirect</method>
70+
</zendesk>
71+
</observers>
72+
</admin_session_user_login_success>
73+
</events>
6474
</global>
6575
<frontend>
6676
<routers>
@@ -171,7 +181,6 @@
171181
</zendesk>
172182
</observers>
173183
</customer_save_commit_after>
174-
175184
</events>
176185
<menu>
177186
<zendesk translate="title" module="zendesk">

0 commit comments

Comments
 (0)