|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** Auth controller */ |
|
11
|
|
|
namespace Auth\Controller; |
|
12
|
|
|
|
|
13
|
|
|
use Auth\AuthenticationService; |
|
14
|
|
|
use Auth\Service\Exception; |
|
15
|
|
|
use Auth\Options\ModuleOptions; |
|
16
|
|
|
use Auth\Form\Login; |
|
17
|
|
|
use Auth\Form\Register; |
|
18
|
|
|
use Zend\Mvc\Controller\AbstractActionController; |
|
19
|
|
|
use Zend\Log\LoggerInterface; |
|
20
|
|
|
use Zend\View\Model\ViewModel; |
|
21
|
|
|
use Zend\View\Model\JsonModel; |
|
22
|
|
|
use Zend\Stdlib\Parameters; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* |
|
26
|
|
|
* @method \Core\Controller\Plugin\Notification notification |
|
27
|
|
|
* @method \Core\Controller\Plugin\Mailer mailer |
|
28
|
|
|
* |
|
29
|
|
|
* Main Action Controller for Authentication module. |
|
30
|
|
|
*/ |
|
31
|
|
|
class IndexController extends AbstractActionController |
|
32
|
|
|
{ |
|
33
|
|
|
|
|
34
|
|
|
const LOGIN='login'; |
|
35
|
|
|
const REGISTER='register'; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var AuthenticationService |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $auth; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var array |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $forms; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var LoggerInterface |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $logger; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var ModuleOptions |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $options; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param $auth AuthenticationService |
|
59
|
|
|
* @param $logger LoggerInterface |
|
60
|
|
|
* @param $forms |
|
61
|
|
|
* @param $options ModuleOptions |
|
62
|
|
|
*/ |
|
63
|
|
|
public function __construct(AuthenticationService $auth, LoggerInterface $logger, array $forms, $options) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->auth = $auth; |
|
66
|
|
|
$this->forms = $forms; |
|
67
|
|
|
$this->logger = $logger; |
|
68
|
|
|
$this->options = $options; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Login with username and password |
|
73
|
|
|
* |
|
74
|
|
|
* @return \Zend\Http\Response|ViewModel |
|
75
|
|
|
*/ |
|
76
|
|
|
public function indexAction() |
|
77
|
|
|
{ |
|
78
|
|
|
if ($this->auth->hasIdentity()) { |
|
79
|
|
|
return $this->redirect()->toRoute('lang'); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$viewModel = new ViewModel(); |
|
83
|
|
|
$services = $this->getServiceLocator(); |
|
84
|
|
|
|
|
85
|
|
|
/* @var $loginForm Login */ |
|
86
|
|
|
$loginForm = $this->forms[self::LOGIN]; |
|
87
|
|
|
/* @var $registerForm Register */ |
|
88
|
|
|
$registerForm = $this->forms[self::REGISTER]; |
|
89
|
|
|
|
|
90
|
|
|
/* @var $request \Zend\Http\Request */ |
|
91
|
|
|
$request = $this->getRequest(); |
|
92
|
|
|
|
|
93
|
|
|
if ($request->isPost()) { |
|
94
|
|
|
$data = $this->params()->fromPost(); |
|
95
|
|
|
$adapter = $services->get('Auth/Adapter/UserLogin'); |
|
96
|
|
|
// inject suffixes via shared Events |
|
97
|
|
|
$loginSuffix = ''; |
|
98
|
|
|
// @TODO: replace this by the Plugin LoginFilter |
|
99
|
|
|
$e = $this->getEvent(); |
|
100
|
|
|
$loginSuffixResponseCollection = $this->getEventManager()->trigger('login.getSuffix', $e); |
|
101
|
|
|
if (!$loginSuffixResponseCollection->isEmpty()) { |
|
102
|
|
|
$loginSuffix = $loginSuffixResponseCollection->last(); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
$loginForm->setData($data); |
|
106
|
|
|
if (array_key_exists('credentials', $data) && |
|
107
|
|
|
array_key_exists('login', $data['credentials']) && |
|
108
|
|
|
array_key_exists('credential', $data['credentials'])) { |
|
109
|
|
|
$adapter->setIdentity($data['credentials']['login'] . $loginSuffix) |
|
110
|
|
|
->setCredential($data['credentials']['credential']); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
$auth = $this->auth; |
|
114
|
|
|
$result = $auth->authenticate($adapter); |
|
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
if ($result->isValid()) { |
|
118
|
|
|
$user = $auth->getUser(); |
|
119
|
|
|
$settings = $user->getSettings('Core'); |
|
120
|
|
|
$language = $settings->localization->language; |
|
121
|
|
View Code Duplication |
if (!$language) { |
|
|
|
|
|
|
122
|
|
|
$headers = $request->getHeaders(); |
|
123
|
|
|
if ($headers->has('Accept-Language')) { |
|
124
|
|
|
$locales = $headers->get('Accept-Language')->getPrioritized(); |
|
125
|
|
|
$language = $locales[0]->type; |
|
126
|
|
|
} else { |
|
127
|
|
|
$language = 'en'; |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
$this->logger->info('User ' . $user->login . ' logged in'); |
|
|
|
|
|
|
131
|
|
|
|
|
132
|
|
|
$ref = $this->params()->fromQuery('ref', false); |
|
133
|
|
|
|
|
134
|
|
|
if ($ref) { |
|
135
|
|
|
$ref = urldecode($ref); |
|
136
|
|
|
$url = preg_replace('~/[a-z]{2}(/|$)~', '/' . $language . '$1', $ref); |
|
137
|
|
|
$url = $request->getBasePath() . $url; |
|
138
|
|
|
} else { |
|
139
|
|
|
$urlHelper = $services->get('ViewHelperManager')->get('url'); |
|
140
|
|
|
$url = $urlHelper('lang', array('lang' => $language)); |
|
141
|
|
|
} |
|
142
|
|
|
$this->notification()->success(/*@translate*/ 'You are now logged in.'); |
|
|
|
|
|
|
143
|
|
|
return $this->redirect()->toUrl($url); |
|
144
|
|
|
} else { |
|
145
|
|
|
$loginName = $data['credentials']['login']; |
|
146
|
|
|
if (!empty($loginSuffix)) { |
|
147
|
|
|
$loginName = $loginName . ' (' . $loginName . $loginSuffix . ')'; |
|
148
|
|
|
} |
|
149
|
|
|
$this->logger->info('Failed to authenticate User ' . $loginName); |
|
150
|
|
|
$this->notification()->danger(/*@translate*/ 'Authentication failed.'); |
|
|
|
|
|
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
$ref = $this->params()->fromQuery('ref', false); |
|
155
|
|
|
|
|
156
|
|
|
if ($ref) { |
|
157
|
|
|
$req = $this->params()->fromQuery('req', false); |
|
158
|
|
|
if ($req) { |
|
159
|
|
|
$this->getResponse()->setStatusCode(403); |
|
|
|
|
|
|
160
|
|
|
$viewModel->setVariable('required', true); |
|
161
|
|
|
} |
|
162
|
|
|
$viewModel->setVariable('ref', $ref); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
$allowRegister = $this->options->getEnableRegistration(); |
|
166
|
|
|
$allowResetPassword = $this->options->getEnableResetPassword(); |
|
167
|
|
|
if (isset($allowRegister)) { |
|
168
|
|
|
$viewModel->setVariables( |
|
169
|
|
|
[ |
|
170
|
|
|
'allowRegister' => $allowRegister, |
|
171
|
|
|
'allowResetPassword' => $allowResetPassword |
|
172
|
|
|
] |
|
173
|
|
|
); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
$viewModel->setVariable('loginForm', $loginForm); |
|
177
|
|
|
$viewModel->setVariable('registerForm', $registerForm); |
|
178
|
|
|
|
|
179
|
|
|
/* @deprecated use loginForm instead of form in your view scripts */ |
|
180
|
|
|
$viewModel->setVariable('form', $loginForm); |
|
181
|
|
|
|
|
182
|
|
|
|
|
183
|
|
|
return $viewModel; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* Login with HybridAuth |
|
188
|
|
|
* |
|
189
|
|
|
* Passed in Params: |
|
190
|
|
|
* - provider: HybridAuth provider identifier. |
|
191
|
|
|
* |
|
192
|
|
|
* Redirects To: Route 'home' |
|
193
|
|
|
*/ |
|
194
|
|
|
public function loginAction() |
|
195
|
|
|
{ |
|
196
|
|
|
$ref = urldecode($this->getRequest()->getBasePath().$this->params()->fromQuery('ref')); |
|
|
|
|
|
|
197
|
|
|
$provider = $this->params('provider', '--keiner--'); |
|
198
|
|
|
$hauth = $this->getServiceLocator()->get('HybridAuthAdapter'); |
|
199
|
|
|
$hauth->setProvider($provider); |
|
200
|
|
|
$auth = $this->auth; |
|
201
|
|
|
$result = $auth->authenticate($hauth); |
|
|
|
|
|
|
202
|
|
|
$resultMessage = $result->getMessages(); |
|
203
|
|
|
|
|
204
|
|
|
if (array_key_exists('firstLogin', $resultMessage) && $resultMessage['firstLogin'] === true) { |
|
205
|
|
|
try { |
|
206
|
|
|
$user = $auth->getUser(); |
|
207
|
|
|
$password = substr(md5(uniqid()), 0, 6); |
|
208
|
|
|
$login = uniqid() . ($this->options->auth_suffix != "" ? '@' . $this->options->auth_suffix : ''); |
|
|
|
|
|
|
209
|
|
|
$externalLogin = isset($user->login)?$user->login:'-- not communicated --'; |
|
|
|
|
|
|
210
|
|
|
$this->logger->debug('first login via ' . $provider . ' as: ' . $externalLogin); |
|
211
|
|
|
|
|
212
|
|
|
$user->login=$login; |
|
|
|
|
|
|
213
|
|
|
$user->setPassword($password); |
|
|
|
|
|
|
214
|
|
|
$user->setRole($this->options->getRole()); |
|
215
|
|
|
|
|
216
|
|
|
$mail = $this->mailer('htmltemplate'); |
|
|
|
|
|
|
217
|
|
|
$mail->setTemplate('mail/first-socialmedia-login'); |
|
218
|
|
|
$mail->setSubject($this->options->getMailSubjectRegistration()); |
|
219
|
|
|
$mail->setVariables( |
|
220
|
|
|
array( |
|
221
|
|
|
'displayName'=> $user->getInfo()->getDisplayName(), |
|
222
|
|
|
'provider' => $provider, |
|
223
|
|
|
'login' => $login, |
|
224
|
|
|
'password' => $password, |
|
225
|
|
|
) |
|
226
|
|
|
); |
|
227
|
|
|
$mail->addTo($user->getInfo()->getEmail()); |
|
228
|
|
|
|
|
229
|
|
|
$loggerId = $login . ' (' . $provider . ': ' . $externalLogin . ')'; |
|
230
|
|
|
if (isset($mail) && $this->mailer($mail)) { |
|
|
|
|
|
|
231
|
|
|
$this->logger->info('Mail first-login for ' . $loggerId . ' sent to ' . $user->getInfo()->getEmail()); |
|
232
|
|
|
} else { |
|
233
|
|
|
$this->logger->warn('No Mail was sent for ' . $loggerId); |
|
234
|
|
|
} |
|
235
|
|
|
} catch (\Exception $e) { |
|
236
|
|
|
$this->logger->crit($e); |
|
237
|
|
|
$this->notification()->danger( |
|
|
|
|
|
|
238
|
|
|
/*@translate*/ 'An unexpected error has occurred, please contact your system administrator' |
|
239
|
|
|
); |
|
240
|
|
|
} |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
$user = $auth->getUser(); |
|
244
|
|
|
$this->logger->info('User ' . $auth->getUser()->getInfo()->getDisplayName() . ' logged in via ' . $provider); |
|
245
|
|
|
$settings = $user->getSettings('Core'); |
|
246
|
|
|
if (null !== $settings->localization->language) { |
|
247
|
|
|
$basePath = $this->getRequest()->getBasePath(); |
|
|
|
|
|
|
248
|
|
|
$ref = preg_replace('~^'.$basePath . '/[a-z]{2}(/)?~', $basePath . '/' . $settings->localization->language . '$1', $ref); |
|
249
|
|
|
} |
|
250
|
|
|
return $this->redirect()->toUrl($ref); |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* Login via an external Application. This will get obsolet as soon we'll have a full featured Rest API. |
|
255
|
|
|
* |
|
256
|
|
|
* Passed in params: |
|
257
|
|
|
* - appKey: Application identifier key |
|
258
|
|
|
* - user: Name of the user to log in |
|
259
|
|
|
* - pass: Password of the user to log in |
|
260
|
|
|
* |
|
261
|
|
|
* Returns an json response with the session-id. |
|
262
|
|
|
* Non existent users will be created! |
|
263
|
|
|
* |
|
264
|
|
|
*/ |
|
265
|
|
|
public function loginExternAction() |
|
266
|
|
|
{ |
|
267
|
|
|
$services = $this->getServiceLocator(); |
|
268
|
|
|
$adapter = $services->get('ExternalApplicationAdapter'); |
|
269
|
|
|
$appKey = $this->params()->fromPost('appKey'); |
|
270
|
|
|
|
|
271
|
|
|
$adapter->setIdentity($this->params()->fromPost('user')) |
|
272
|
|
|
->setCredential($this->params()->fromPost('pass')) |
|
273
|
|
|
->setApplicationKey($appKey); |
|
274
|
|
|
|
|
275
|
|
|
$auth = $this->auth; |
|
276
|
|
|
$result = $auth->authenticate($adapter); |
|
|
|
|
|
|
277
|
|
|
|
|
278
|
|
|
if ($result->isValid()) { |
|
279
|
|
|
$this->logger->info( |
|
280
|
|
|
'User ' . $this->params()->fromPost('user') . |
|
281
|
|
|
' logged via ' . $appKey |
|
282
|
|
|
); |
|
283
|
|
|
|
|
284
|
|
|
// the external login may include some parameters for an update |
|
285
|
|
|
$updateParams = $this->params()->fromPost(); |
|
286
|
|
|
unset($updateParams['user'], $updateParams['pass'], $updateParams['appKey']); |
|
287
|
|
|
$resultMessage = $result->getMessages(); |
|
288
|
|
|
$password = null; |
|
289
|
|
|
if (array_key_exists('firstLogin', $resultMessage) && $resultMessage['firstLogin'] === true) { |
|
290
|
|
|
$password = substr(md5(uniqid()), 0, 6); |
|
291
|
|
|
$updateParams['password'] = $password; |
|
292
|
|
|
} |
|
293
|
|
|
if (!empty($updateParams)) { |
|
294
|
|
|
$user = $auth->getUser(); |
|
295
|
|
|
try { |
|
296
|
|
|
foreach ($updateParams as $updateKey => $updateValue) { |
|
297
|
|
|
if ('email' == $updateKey) { |
|
298
|
|
|
$user->info->email = $updateValue; |
|
|
|
|
|
|
299
|
|
|
} |
|
300
|
|
|
$user->$updateKey = $updateValue; |
|
301
|
|
|
} |
|
302
|
|
|
} catch (Exception $e) { |
|
|
|
|
|
|
303
|
|
|
} |
|
304
|
|
|
$services->get('repositories')->store($user); |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
$resultMessage = $result->getMessages(); |
|
308
|
|
|
// TODO: send a mail also when required (maybe first mail failed or email has changed) |
|
309
|
|
|
if (array_key_exists('firstLogin', $resultMessage) && $resultMessage['firstLogin'] === true) { |
|
310
|
|
|
// first external Login |
|
311
|
|
|
$userName = $this->params()->fromPost('user'); |
|
312
|
|
|
$this->logger->debug('first login for User: ' . $userName); |
|
313
|
|
|
// |
|
314
|
|
|
if (preg_match("/^(.*)@\w+$/", $userName, $realUserName)) { |
|
315
|
|
|
$userName = $realUserName[1]; |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
$mail = $this->mailer('htmltemplate'); /* @var $mail \Core\Mail\HTMLTemplateMessage */ |
|
|
|
|
|
|
319
|
|
|
$apps = $this->config('external_applications'); |
|
|
|
|
|
|
320
|
|
|
$apps = array_flip($apps); |
|
321
|
|
|
$application = isset($apps[$appKey]) ? $apps[$appKey] : null; |
|
322
|
|
|
|
|
323
|
|
|
$mail->setVariables( |
|
324
|
|
|
array( |
|
325
|
|
|
'application' => $application, |
|
326
|
|
|
'login'=>$userName, |
|
327
|
|
|
'password' => $password, |
|
328
|
|
|
) |
|
329
|
|
|
); |
|
330
|
|
|
$mail->setSubject($this->options->getMailSubjectRegistration()); |
|
331
|
|
|
$mail->setTemplate('mail/first-external-login'); |
|
332
|
|
|
$mail->addTo($user->getInfo()->getEmail()); |
|
|
|
|
|
|
333
|
|
|
|
|
334
|
|
|
try { |
|
335
|
|
|
$this->mailer($mail); |
|
|
|
|
|
|
336
|
|
|
$this->logger->info('Mail first-login sent to ' . $userName); |
|
337
|
|
|
} catch (\Zend\Mail\Transport\Exception\ExceptionInterface $e) { |
|
338
|
|
|
$this->logger->warn('No Mail was sent'); |
|
339
|
|
|
$this->logger->debug($e); |
|
|
|
|
|
|
340
|
|
|
} |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
return new JsonModel( |
|
344
|
|
|
array( |
|
345
|
|
|
'status' => 'success', |
|
346
|
|
|
'token' => session_id() |
|
347
|
|
|
) |
|
348
|
|
|
); |
|
349
|
|
|
} else { |
|
350
|
|
|
$this->logger->info( |
|
351
|
|
|
'Failed to authenticate User ' . $this->params()->fromPost('user') . |
|
352
|
|
|
' via ' . $this->params()->fromPost('appKey') |
|
353
|
|
|
); |
|
354
|
|
|
|
|
355
|
|
|
$this->getResponse()->setStatusCode(403); |
|
|
|
|
|
|
356
|
|
|
return new JsonModel( |
|
357
|
|
|
array( |
|
358
|
|
|
'status' => 'failure', |
|
359
|
|
|
'user' => $this->params()->fromPost('user'), |
|
360
|
|
|
'appKey' => $this->params()->fromPost('appKey'), |
|
361
|
|
|
'code' => $result->getCode(), |
|
362
|
|
|
'messages' => $result->getMessages(), |
|
363
|
|
|
) |
|
364
|
|
|
); |
|
365
|
|
|
} |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
public function groupAction() |
|
369
|
|
|
{ |
|
370
|
|
|
//$adapter = $this->getServiceLocator()->get('ExternalApplicationAdapter'); |
|
|
|
|
|
|
371
|
|
|
if (false) { |
|
|
|
|
|
|
372
|
|
|
$this->request->setMethod('get'); |
|
|
|
|
|
|
373
|
|
|
$params = new Parameters( |
|
374
|
|
|
array( |
|
375
|
|
|
'format' => 'json', |
|
376
|
|
|
'group' => array( |
|
377
|
|
|
0 => 'testuser4711', 1 => 'flatscreen', 2 => 'flatscreen1', 3 => 'flatscreen2', 4 => 'flatscreen3', 5 => 'flatscreen4', |
|
378
|
|
|
6 => 'flatscreen5', 7 => 'flatscreen6', 8 => 'flatscreen7', 9 => 'flatscreen8', 10 => 'flatscreen9' |
|
379
|
|
|
), |
|
380
|
|
|
'name' => '(die) Rauscher – Unternehmensberatung & Consulting', |
|
381
|
|
|
) |
|
382
|
|
|
); |
|
383
|
|
|
$this->getRequest()->setQuery($params); |
|
|
|
|
|
|
384
|
|
|
} |
|
385
|
|
|
$auth = $this->auth; |
|
386
|
|
|
$userGrpAdmin = $auth->getUser(); |
|
387
|
|
|
$this->logger->info('User ' . $auth->getUser()->getInfo()->getDisplayName()); |
|
388
|
|
|
$grp = $this->params()->fromQuery('group'); |
|
|
|
|
|
|
389
|
|
|
|
|
390
|
|
|
// if the request is made by an external host, add his identification-key to the name |
|
391
|
|
|
$loginSuffix = ''; |
|
392
|
|
|
// @TODO: replace this by the Plugin LoginFilter |
|
393
|
|
|
$e = $this->getEvent(); |
|
394
|
|
|
$loginSuffixResponseCollection = $this->getEventManager()->trigger('login.getSuffix', $e); |
|
395
|
|
|
if (!$loginSuffixResponseCollection->isEmpty()) { |
|
396
|
|
|
$loginSuffix = $loginSuffixResponseCollection->last(); |
|
397
|
|
|
} |
|
398
|
|
|
// make out of the names a list of Ids |
|
399
|
|
|
$params = $this->getRequest()->getQuery(); |
|
|
|
|
|
|
400
|
|
|
$groupUserId = array(); |
|
401
|
|
|
$notFoundUsers = array(); |
|
402
|
|
|
//$users = $this->getRepository(); |
|
|
|
|
|
|
403
|
|
|
$users = $this->getServiceLocator()->get('repositories')->get('Auth/User'); |
|
404
|
|
|
if (!empty($params->group)) { |
|
405
|
|
|
foreach ($params->group as $grp_member) { |
|
|
|
|
|
|
406
|
|
|
try |
|
407
|
|
|
{ |
|
408
|
|
|
$user = $users->findByLogin($grp_member . $loginSuffix); |
|
|
|
|
|
|
409
|
|
|
if (!empty($user)) { |
|
410
|
|
|
$groupUserId[] = $user->id; |
|
411
|
|
|
} else { |
|
412
|
|
|
$notFoundUsers[] = $grp_member . $loginSuffix; |
|
|
|
|
|
|
413
|
|
|
} |
|
414
|
|
|
} |
|
415
|
|
|
catch (\Auth\Exception\UserDeactivatedException $e) |
|
416
|
|
|
{ |
|
417
|
|
|
$notFoundUsers[] = $grp_member . $loginSuffix; |
|
|
|
|
|
|
418
|
|
|
} |
|
419
|
|
|
} |
|
420
|
|
|
} |
|
421
|
|
|
$name = $params->name; |
|
422
|
|
|
if (!empty($params->name)) { |
|
423
|
|
|
$group = $this->auth()->getUser()->getGroup($params->name, /*create*/ true); |
|
|
|
|
|
|
424
|
|
|
$group->setUsers($groupUserId); |
|
425
|
|
|
} |
|
426
|
|
|
$this->logger->info( |
|
427
|
|
|
'Update Group Name: ' . $name . PHP_EOL . str_repeat(' ', 36) . 'Group Owner: ' . $userGrpAdmin->getLogin() . PHP_EOL . |
|
428
|
|
|
str_repeat(' ', 36) . 'Group Members Param: ' . implode(',', $params->group) . PHP_EOL . |
|
429
|
|
|
str_repeat(' ', 36) . 'Group Members: ' . count($groupUserId) . PHP_EOL . str_repeat(' ', 36) . 'Group Members not found: ' . implode(',', $notFoundUsers) |
|
430
|
|
|
); |
|
431
|
|
|
|
|
432
|
|
|
return new JsonModel( |
|
433
|
|
|
array( |
|
434
|
|
|
) |
|
435
|
|
|
); |
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
/** |
|
439
|
|
|
* Logout |
|
440
|
|
|
* |
|
441
|
|
|
* Redirects To: Route 'home' |
|
442
|
|
|
*/ |
|
443
|
|
|
public function logoutAction() |
|
|
|
|
|
|
444
|
|
|
{ |
|
445
|
|
|
$auth = $this->auth; |
|
446
|
|
|
$this->logger->info('User ' . ($auth->getUser()->login==''?$auth->getUser()->info->displayName:$auth->getUser()->login) . ' logged out'); |
|
|
|
|
|
|
447
|
|
|
$auth->clearIdentity(); |
|
448
|
|
|
unset($_SESSION['HA::STORE']); |
|
449
|
|
|
|
|
450
|
|
|
$this->notification()->success(/*@translate*/ 'You are now logged out'); |
|
|
|
|
|
|
451
|
|
|
return $this->redirect()->toRoute( |
|
452
|
|
|
'lang', |
|
453
|
|
|
array('lang' => $this->params('lang')) |
|
454
|
|
|
); |
|
455
|
|
|
} |
|
456
|
|
|
} |
|
457
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: