-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
286 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
namespace Auth\Controller; | ||
|
||
use Auth\AuthenticationService; | ||
use Auth\Service\Exception; | ||
use Zend\Mvc\Controller\AbstractActionController; | ||
use Zend\Log\LoggerInterface; | ||
use Zend\View\Model\ViewModel; | ||
|
@@ -38,14 +39,20 @@ class IndexController extends AbstractActionController | |
*/ | ||
protected $logger; | ||
|
||
/** | ||
* @var | ||
*/ | ||
protected $options; | ||
|
||
/** | ||
* @param $auth | ||
* @param $loginForm | ||
*/ | ||
public function __construct($auth,$logger,$loginForm) { | ||
public function __construct($auth, $logger, $loginForm, $options) { | ||
$this->auth=$auth; | ||
$this->loginForm=$loginForm; | ||
$this->logger=$logger; | ||
$this->options = $options; | ||
} | ||
|
||
/** | ||
|
@@ -163,14 +170,12 @@ public function loginAction() | |
$resultMessage = $result->getMessages(); | ||
|
||
if (array_key_exists('firstLogin', $resultMessage) && $resultMessage['firstLogin'] === True) { | ||
$this->logger->debug('first login via ' . $provider); | ||
|
||
if (array_key_exists('user', $resultMessage)) { | ||
$user=$auth->getUser(); | ||
|
||
$password = substr(md5(uniqid()),0,6); | ||
|
||
$login = uniqid() . ($config['auth']['suffix']!=""?'@'.$config['auth']['suffix']:''); | ||
try { | ||
$user = $auth->getUser(); | ||
$password = substr(md5(uniqid()),0,6); | ||
$login = uniqid() . ($this->options->auth_suffix != "" ? '@' . $this->options->auth_suffix : ''); | ||
$externalLogin = isset($user->login)?$user->login:'-- not communicated --'; | ||
$this->logger->debug('first login via ' . $provider . ' as: ' . $externalLogin); | ||
|
||
$scheme = ''; | ||
$domain = ''; | ||
|
@@ -181,33 +186,42 @@ public function loginAction() | |
} | ||
$viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager'); | ||
$basePath = $viewHelperManager->get('basePath')->__invoke(); | ||
|
||
$user->login=$login; | ||
$user->setPassword($password); | ||
$user->role=$config['first_login']['role']; | ||
$user->role = $this->options->role; | ||
|
||
$mail = $this->mail( | ||
array('displayName'=>$user->info->getDisplayName(), | ||
'provider' => $provider, | ||
'user' => $login, | ||
'password' => $password, | ||
'uri' => $scheme . '://' . $domain . $basePath) | ||
array( 'from' => $this->options->mail_from, | ||
'fromName' => $this->options->mail_name, | ||
'subject' => 'registration at the YAWIK', | ||
'displayName'=> $user->info->getDisplayName(), | ||
'provider' => $provider, | ||
'user' => $login, | ||
'password' => $password, | ||
'uri' => $scheme . '://' . $domain . $basePath) | ||
); | ||
$mail->template('first-login'); | ||
$mail->addTo($user->info->getEmail()); | ||
$mail->setFrom('[email protected]', $config['first_login']['mail_name']); | ||
$mail->setSubject($config['first_login']['mail_subject']); | ||
$mail->setSubject($this->options->mail_subject); | ||
|
||
$loggerId = $login . ' (' . $provider . ': ' . $externalLogin . ')'; | ||
if (isset($mail) && $this->mailer($mail)) { | ||
$this->logger->info('Mail first-login for ' . $loggerId . ' sent to ' . $user->info->getEmail()); | ||
} else { | ||
$this->logger->warn('No Mail was sent for ' . $loggerId); | ||
} | ||
} | ||
if (isset($mail) && $this->mailer($mail)) { | ||
$this->logger->info('Mail first-login sent to ' . $user->info->getEmail()); | ||
} else { | ||
$this->logger->warn('No Mail was sent'); | ||
catch (\Exception $e) { | ||
$this->logger->crit($e); | ||
$this->notification()->danger( | ||
/*@translate*/ 'An unexpected error has occurred, please contact your system administrator' | ||
); | ||
} | ||
|
||
} | ||
|
||
$user = $auth->getUser(); | ||
$this->logger->info('User ' . $auth->getUser()->getInfo()->getDisplayName() . ' logged in via ' . $provider); | ||
//$user = $auth->getUser(); | ||
//$this->logger->info('User ' . $auth->getUser()->getInfo()->getDisplayName() . ' logged in via ' . $provider); | ||
$settings = $user->getSettings('Core'); | ||
if (null !== $settings->localization->language) { | ||
$basePath = $this->getRequest()->getBasePath(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
184 changes: 184 additions & 0 deletions
184
module/Auth/src/Auth/Options/ControllerIndexOptions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
<?php | ||
/** | ||
* YAWIK | ||
* | ||
* @filesource | ||
* @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de) | ||
* @license MIT | ||
* @author [email protected] | ||
*/ | ||
|
||
namespace Auth\Options; | ||
|
||
use Zend\Stdlib\AbstractOptions; | ||
|
||
/** | ||
* Class ListenerPublisherOptions | ||
* @package YawikXingVendorApi\Options | ||
*/ | ||
class ControllerIndexOptions extends AbstractOptions { | ||
|
||
/** | ||
* the preview indicates, that a job is not shown | ||
* @var bool | ||
*/ | ||
protected $fromEmail = '[email protected]'; | ||
|
||
/** | ||
* if no organizationId was set, return the id of the Sandbox | ||
* Jobs in the sandbox can not be inspected in the backend, their | ||
* only function is to get a negative or positive answer from the transmit | ||
* @var string | ||
*/ | ||
protected $fromName = 'YAWIK'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $role = 'recruiter'; | ||
|
||
/** | ||
* @var | ||
*/ | ||
protected $mailName = 'Yawik'; | ||
|
||
/** | ||
* @var | ||
*/ | ||
protected $mailFrom = '[email protected]'; | ||
|
||
/** | ||
* @var | ||
*/ | ||
protected $mailSubject = 'Welcome to YAWIK'; | ||
|
||
/** | ||
* @var | ||
*/ | ||
protected $authSuffix = 'yawik'; | ||
|
||
/** | ||
* @param $role | ||
* @return $this | ||
*/ | ||
public function setRole($role) | ||
{ | ||
$this->role = $role; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRole() | ||
{ | ||
return $this->role; | ||
} | ||
|
||
/** | ||
* @param $mailName | ||
* @return $this | ||
*/ | ||
public function setMailName($mailName) | ||
{ | ||
$this->mailName = $mailName; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMailName() | ||
{ | ||
return $this->mailName; | ||
} | ||
|
||
/** | ||
* @param $mail | ||
* @return $this | ||
*/ | ||
public function setMailFrom($mail) | ||
{ | ||
$this->fromEmail = $mail; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMailFrom() | ||
{ | ||
return $this->mailFrom; | ||
} | ||
|
||
/** | ||
* @param $subject | ||
* @return $this | ||
*/ | ||
public function setMailSubject($subject) | ||
{ | ||
$this->mailSubject = $subject; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMailSubject() | ||
{ | ||
return $this->mailSubject; | ||
} | ||
|
||
/** | ||
* @param $suffix | ||
* @return $this | ||
*/ | ||
public function setAuthSuffix($suffix) | ||
{ | ||
$this->authSuffix = $suffix; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getAuthSuffix() | ||
{ | ||
return $this->authSuffix; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function getEmail() | ||
{ | ||
return $this->fromEmail; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function setEmail($fromEmail) | ||
{ | ||
$this->fromEmail = $fromEmail; | ||
return $this; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->fromName; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function setName($fromName) | ||
{ | ||
$this->fromName = $fromName; | ||
return $this; | ||
} | ||
|
||
} |
Oops, something went wrong.