Skip to content

Commit

Permalink
A proper merge of sourcefabric#918 into 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
takeit committed Mar 4, 2015
1 parent f70052c commit 8269cc5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
36 changes: 22 additions & 14 deletions newscoop/application/controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public function indexAction()
$result = $this->auth->authenticate($adapter);

if ($result->getCode() == Zend_Auth_Result::SUCCESS) {
setcookie('NO_CACHE', '1', NULL, '/', '.'.$this->extractDomain($_SERVER['HTTP_HOST']));
setcookie('NO_CACHE', '1', null, '/', '.'.$this->extractDomain($_SERVER['HTTP_HOST']));
if (isset($values['_target_path'])) {
$this->_helper->redirector->gotoUrl($values['_target_path']);
}

$this->_helper->redirector('index', 'dashboard');
} else {
$form->addError($translator->trans("Invalid credentials"));
Expand All @@ -58,25 +62,25 @@ public function logoutAction()
$this->_redirect($url);
}

$this->_helper->redirector->gotoUrl('?t=' . time());
$this->_helper->redirector->gotoUrl('?t='.time());
}

public function socialAction()
{
{
$preferencesService = \Zend_Registry::get('container')->getService('system_preferences_service');
$userService = \Zend_Registry::get('container')->getService('user');
$session = \Zend_Registry::get('container')->getService('session');

$config = array(
'base_url' => $this->view->serverUrl($this->view->url(array('action' => 'socialendpoint'))),
'debug_mode' => false,
'providers' => array(
'Facebook' => array(
'enabled' => true,
'base_url' => $this->view->serverUrl($this->view->url(array('action' => 'socialendpoint'))),
'debug_mode' => false,
'providers' => array(
'Facebook' => array(
'enabled' => true,
'keys' => array(
'id' => $preferencesService->facebook_appid,
'secret' => $preferencesService->facebook_appsecret,
),
),
),
),
);
Expand Down Expand Up @@ -106,12 +110,17 @@ public function socialAction()
$OAuthtoken = $userService->loginUser($user, 'oauth_authorize');
$session->set('_security_oauth_authorize', serialize($OAuthtoken));
}
setcookie('NO_CACHE', '1', NULL, '/', '.'.$this->extractDomain($_SERVER['HTTP_HOST']));
setcookie('NO_CACHE', '1', null, '/', '.'.$this->extractDomain($_SERVER['HTTP_HOST']));
if ($user->isPending()) {
$this->_forward('confirm', 'register', 'default', array(
'social' => true,
));
} else {
$request = $this->getRequest();
if ($request->getParam('_target_path')) {
$this->_helper->redirector->gotoUrl($request->getParam('_target_path'));
}

$this->_helper->redirector('index', 'dashboard');
}
} catch (\Exception $e) {
Expand Down Expand Up @@ -140,7 +149,7 @@ public function passwordRestoreAction()
$this->_helper->service('email')->sendPasswordRestoreToken($user);
$this->_helper->flashMessenger($translator->trans("E-mail with instructions was sent to given email address."));
$this->_helper->redirector('password-restore-after', 'auth');
} else if (empty($user)) {
} elseif (empty($user)) {
$form->email->addError($translator->trans("Given email not found."));
}
}
Expand All @@ -153,7 +162,7 @@ public function passwordRestoreAfterAction()
}

public function passwordRestoreFinishAction()
{
{
$translator = Zend_Registry::get('container')->getService('translator');
$user = $this->_helper->service('user')->find($this->_getParam('user'));
if (empty($user)) {
Expand Down Expand Up @@ -198,8 +207,7 @@ public function passwordRestoreFinishAction()

private function extractDomain($domain)
{
if(preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i", $domain, $matches))
{
if (preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i", $domain, $matches)) {
return $matches['domain'];
} else {
return $domain;
Expand Down
4 changes: 4 additions & 0 deletions newscoop/application/forms/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class Application_Form_Login extends Zend_Form
{
public function init()
{
$this->addElement('hidden', '_target_path', array(
'value' => $_SERVER['REQUEST_URI'],
));

$this->addElement('text', 'email', array(
'label' => 'Email',
'required' => true,
Expand Down

0 comments on commit 8269cc5

Please sign in to comment.