Skip to content

Commit

Permalink
[Auth] fixes sending of welcome mails
Browse files Browse the repository at this point in the history
  • Loading branch information
cbleek committed May 12, 2015
1 parent d8e4114 commit a7e7c07
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
1 change: 1 addition & 0 deletions module/Auth/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@
'auth/form/social-profiles-button' => __DIR__ . '/../view/form/social-profiles-button.phtml',
'auth/sidebar/groups-menu' => __DIR__ . '/../view/sidebar/groups-menu.phtml',
'mail/first-external-login' => __DIR__ . '/../view/mail/first-external-login.phtml',
'mail/first-socialmedia-login' => __DIR__ . '/../view/mail/first-socialmedia-login.phtml',
'mail/forgotPassword' => __DIR__ . '/../view/mail/forgot-password.phtml',
'mail/register' => __DIR__ . '/../view/mail/register.phtml',
),
Expand Down
1 change: 1 addition & 0 deletions module/Auth/src/Auth/Adapter/HybridAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public function authenticate()

$forceSave = false;
$user = $this->getRepository()->findByProfileIdentifier($userProfile->identifier);

if (!$user) {
$forceSave = true;
$user = $this->getRepository()->create();
Expand Down
32 changes: 11 additions & 21 deletions module/Auth/src/Auth/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class IndexController extends AbstractActionController
protected $options;

/**
* @param $auth
* @param $logger
* @param $auth AuthenticationService
* @param $logger LoggerInterface
* @param $loginForm
* @param $options
*/
public function __construct($auth, $logger, $loginForm, $options) {
public function __construct(AuthenticationService $auth, LoggerInterface $logger, $loginForm, $options) {
$this->auth=$auth;
$this->loginForm=$loginForm;
$this->logger=$logger;
Expand Down Expand Up @@ -174,10 +174,8 @@ public function indexAction()
*/
public function loginAction()
{

$ref = urldecode($this->getRequest()->getBasePath().$this->params()->fromQuery('ref'));
$provider = $this->params('provider', '--keiner--');
$config = $this->config();
$hauth = $this->getServiceLocator()->get('HybridAuthAdapter');
$hauth->setProvider($provider);
$auth = $this->auth;
Expand All @@ -192,28 +190,20 @@ public function loginAction()
$externalLogin = isset($user->login)?$user->login:'-- not communicated --';
$this->logger->debug('first login via ' . $provider . ' as: ' . $externalLogin);

$scheme = '';
$domain = '';
$uri = $this->getRequest()->getUri();
if (isset($uri)) {
$scheme = $uri->getScheme();
$domain = $uri->getHost();
}
$viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
$basePath = $viewHelperManager->get('basePath')->__invoke();

$user->login=$login;
$user->setPassword($password);
$user->role = $this->options->role;
$user->role = $this->options->getRole();

$mail = $this->mailer('htmltemplate');
$mail->setTemplate('mail/first-socialmedia-login');
$mail->setSubject($this->options->getMailSubjectRegistration());
$mail->setVariables(array(
'displayName'=> $user->info->getDisplayName(),
'provider' => $provider,
'user' => $login,
'login' => $login,
'password' => $password,
));
'link' => $this->url()->fromRoute('lang/auth', array(), array())));

$mail->addTo($user->info->getEmail());

$loggerId = $login . ' (' . $provider . ': ' . $externalLogin . ')';
Expand All @@ -231,8 +221,8 @@ public function loginAction()
}
}

//$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();
Expand Down Expand Up @@ -298,7 +288,7 @@ public function loginExternAction()
if (array_key_exists('firstLogin', $resultMessage) && $resultMessage['firstLogin'] === True) {
// first external Login
$userName = $this->params()->fromPost('user');
$this->getServiceLocator()->get('Core/Log')->debug('first login for User: ' . $userName);
$this->logger->debug('first login for User: ' . $userName);
//
if (preg_match("/^(.*)@\w+$/", $userName, $realUserName)) {
$userName = $realUserName[1];
Expand Down
4 changes: 2 additions & 2 deletions module/Auth/view/mail/first-socialmedia-login.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


<p>Login data were generated, so you can log into YAWIK directly. This should only show you that YAWIK can be used completely
without social networks. Althought there are no registration forms yet.</p>
without social networks.</p>

<p>We've set your role to a recruiter. So you can create jobs and manage applications. You can change your role in your profile.</p>

Expand All @@ -16,7 +16,7 @@ without social networks. Althought there are no registration forms yet.</p>
Secret: <?php echo $this->password ?></p>


<p>Return to YAWIK and log in at: <?php echo $this->url(array('lang/auth'), array('lang' => 'de')) ?></p>
<p>Return to YAWIK and log in at: <?php echo $this->link ?></p>


<p>regards,</p>
Expand Down
3 changes: 3 additions & 0 deletions module/Jobs/src/Jobs/Entity/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ public function getDescription()
* @see \Jobs\Entity\JobInterface::getCompany()
*/
public function getCompany() {
if ($this->organization) {
return $this->organization->getOrganizationName()->getName();
}
return $this->company;
}

Expand Down
2 changes: 1 addition & 1 deletion module/Jobs/view/jobs/manage/form.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $channels=array("yawik" =>
"price" => /*@translate*/ "free"),
"jobsintown" =>
array(
"label" => "www.obsintown.de",
"label" => "www.jobsintown.de",
"price" => "199 €"),
"homepage" =>
array(
Expand Down

0 comments on commit a7e7c07

Please sign in to comment.