-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
817 lines (707 loc) · 25.2 KB
/
test.php
File metadata and controls
817 lines (707 loc) · 25.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
<?php
namespace Producteev\CoreBundle\Service;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Translation\Translator;
use Producteev\CoreBundle\Manager\UserManager;
use Producteev\CoreBundle\Document\User;
use Producteev\CoreBundle\Document\Project;
use Producteev\CoreBundle\Document\File;
use Producteev\CoreBundle\Document\Network;
use Producteev\CoreBundle\Utils\StrCleaner;
use Producteev\CoreBundle\Exception\InputInvalidException;
use Producteev\CoreBundle\Exception\IntegrityConstraintException;
use Producteev\CoreBundle\Service\AvatarService;
use Producteev\CoreBundle\Event\UserEvent;
use Producteev\CoreBundle\Utils\EmailManager;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Producteev\CoreBundle\Privacy\ProjectPrivacy;
use Predis\Client as RedisClient;
use Producteev\CoreBundle\Utils\StrSearch as StrSearchUtil;
use Producteev\CoreBundle\Service\NetworkService;
class UserService extends ProducteevBaseService
{
private $avatarService;
private $eventDispatcher;
private $emailManager;
private $redisClient;
private $pwdRedisKeyLifetime;
private $strSearchUtil;
private $verificationTokenLifetime;
const EMAIL_CATEGORY_RESET_PASSWORD_REQUEST = "user.resetpasswordrequest.passwordtoken";
const EMAIL_TEMPLATE_RESET_PASSWORD_REQUEST = "email.user.resetpasswordrequest";
const PASSWORD_TOKEN_REDIS_KEY_PREFIX = "useraccount_passwordtoken_";
const VERIFICATION_TOKEN_REDIS_KEY_PREFIX = "useraccount_veriftoken_";
const EMAIL_CATEGORY_RESET_PASSWORD_CONFIRMATION = "user.resetpassword.confirmation";
const EMAIL_TEMPLATE_RESET_PASSWORD_CONFIRMATION = "email.user.resetpasswordconfirmation";
public function __construct(UserManager $userManager, AvatarService $avatarService,
EventDispatcher $eventDispatcher, EmailManager $emailManager, Translator $translator, RedisClient $redisClient, $pwdTokenRedisKeyLifetime,
Router $router, ProjectPrivacy $projectPrivacy, StrSearchUtil $strSearchUtil, $verificationTokenLifetime, NetworkService $networkService)
{
parent::__construct($userManager);
$this->avatarService = $avatarService;
$this->eventDispatcher = $eventDispatcher;
$this->emailManager = $emailManager;
$this->translator = $translator;
$this->redisClient = $redisClient;
$this->pwdTokenRedisKeyLifetime = $pwdTokenRedisKeyLifetime;
$this->router = $router;
$this->projectPrivacy = $projectPrivacy;
$this->strSearchUtil = $strSearchUtil;
$this->verificationTokenLifetime = $verificationTokenLifetime;
$this->networkService = $networkService;
}
/**
* Signup a new user
*
* @param string $email
* @param string $password
* @param string $firstname
* @param string $lastname
* @param optional string $timezone
* @param optional string $jobTitle
* @param optional string $ipAddress
* @return User $user
*/
public function signup($email, $password, $firstname, $lastname, $timezone = "UTC", $jobTitle = null, $ipAddress = null)
{
$user = $this->createUser($email, $firstname, $lastname, $timezone, $jobTitle, $ipAddress);
$this->objectManager->setPassword($password, $user);
$this->objectManager->persist($user);
//Send an email to the user to verified is account
$this->sendVerificationEmail($user, true);
$event = new UserEvent($user);
$this->eventDispatcher->dispatch(UserEvent::SIGNUP, $event);
return $user;
}
/**
* Signup a facebook new user
*
* @param string $email
* @param string $firstname
* @param string $lastname
* @param string $facebookId
* @param optional string $timezone
* @return User $user
*/
public function signupFacebookUser($email, $firstname, $lastname, $facebookId, $timezone = "UTC", $jobTitle = null, $ipAddress = null)
{
$user = $this->createUser($email, $firstname, $lastname, $timezone, $jobTitle, $ipAddress);
$this->objectManager->setFacebookId($user, $facebookId);
//Facebook user is verified by facebook authentication process
$this->objectManager->switchToVerified($user);
$this->objectManager->persist($user);
$event = new UserEvent($user);
$this->eventDispatcher->dispatch(UserEvent::SIGNUP, $event);
return $user;
}
/**
* Create a new user
*
* @param string $email
* @param string $firstname
* @param string $lastname
* @param optional string $timezone
* @return User $user
*/
private function createUser($email, $firstname, $lastname, $timezone = "UTC", $jobTitle = null, $ipAddress = null)
{
$user = $this->objectManager->create();
$this->objectManager->setEmail($user, $email);
$this->objectManager->setName($user, $firstname, $lastname);
$this->objectManager->setTimezone($user, $timezone);
$this->objectManager->setJobTitle($user, $jobTitle);
$this->objectManager->setIpAddress($user, $ipAddress);
return $user;
}
/**
* Set $email for the $user
*
* @param string $email
* @param Model\User $user
* @return User $user
*/
public function setEmail($email, User $user)
{
$this->objectManager->setEmail($user, $email);
$this->objectManager->persist($user);
return $user;
}
/**
* Set the $password for the $user
*
* @param string $password
* @param Model\User $user
* @return User $user
*/
public function setPassword($password, User $user)
{
$this->objectManager->setPassword($password, $user);
$this->objectManager->persist($user);
return $user;
}
/**
* Set the v3 hash as password for the $user
*
* @param string $hash
* @param Model\User $user
* @return User $user
*/
public function setV3Password($hash, User $user)
{
$this->objectManager->setV3Password($hash, $user);
$this->objectManager->persist($user);
return $user;
}
/**
* Set user's name
*
* @param User $user
* @param string $firstname
* @param string $lastname
* @return User $user
*/
public function setName(User $user, $firstname, $lastname)
{
$this->objectManager->setName($user, $firstname, $lastname);
$this->objectManager->persist($user);
return $user;
}
/**
* Set user firstname
*
* @param User $user
* @param string $firstname
* @return User $user
*/
public function setFirstname(User $user, $firstname)
{
$this->objectManager->setFirstname($user, $firstname);
$this->objectManager->persist($user);
return $user;
}
/**
* Set user lastname
*
* @param User $user
* @param string $lastname
* @return User $user
*/
public function setLastname(User $user, $lastname)
{
$this->objectManager->setLastname($user, $lastname);
$this->objectManager->persist($user);
return $user;
}
/**
* Set an avatar for a user
*
* @param User $user
* @param string $localPath avatar file on the local file system
* @return User $user
*/
public function setAvatar(User $user, $localPath)
{
$hashAvatar = $this->avatarService->set($user, $localPath);
$this->objectManager->setAvatar($user, $hashAvatar);
$this->objectManager->persist($user);
return $user;
}
/**
* Clear the user avatar
*
* @param User $user
* @return User $user
*/
public function clearAvatar(User $user)
{
$this->objectManager->setAvatar($user, null);
$this->objectManager->persist($user);
return $user;
}
/**
* Set an avatar for a user from a remote url
*
* @param User $user
* @param string $url avatar file remote url
* @return User $user
*/
public function setAvatarFromRemoteUrl(User $user, $url)
{
if(!mb_strlen($url)) {
throw new InputInvalidException($this->translator->trans("core.inputinvalidexception.remotefile_no_url"));
}
$hashAvatar = $this->avatarService->setRemoteFile($user, $url);
$this->objectManager->setAvatar($user, $hashAvatar);
$this->objectManager->persist($user);
return $user;
}
/**
* Set the timezone for a user
*
* @param User $user
* @param string $timezone
* @return User $user
*/
public function setTimezone(User $user, $timezone)
{
$this->objectManager->setTimezone($user, $timezone);
$this->objectManager->persist($user);
return $user;
}
/**
* Set the $user jobTitle
*
* @param User $user
* @param string $jobTitle
* @return User $user
*/
public function setJobTitle(User $user, $jobTitle)
{
$this->objectManager->setJobTitle($user, $jobTitle);
$this->objectManager->persist($user);
return $user;
}
/**
* Find a user by his id, with the right of the $user
*
* @param User $user
* @param string $id
* @return User $user
* @todo handle privacy before production
*/
public function findOneById(User $user, $id)
{
$user = $this->objectManager->findOneById($id);
return $user;
}
/**
* Check if the $email is already attached to a user
*
* @param string $email
* @return bool
*/
public function checkEmailExists($email)
{
$user = $this->objectManager->findOneByEmail($email);
return ($user !== null);
}
/**
* Generate a new password token and send an email
*
* @param String $email
* @return User $user
*/
public function requestPasswordReset($email)
{
//Get the user by email address
$user = $this->objectManager->findOneByEmail($email);
if ($user == null) {
throw new InputInvalidException($this->translator->trans("core.inputinvalidexception.unknown_email_address", array("%email%" => $email)));
}
//generate a new password token and save it
$this->objectManager->generateNewPasswordToken($user);
$this->objectManager->persist($user);
//Save the key in redis with an expiration time
$redisKey = $this->getPasswordTokenRedisKey($user->getLastPasswordToken());
$this->redisClient->set($redisKey, $user->getId());
$expiration = $this->pwdTokenRedisKeyLifetime;
$this->redisClient->expire($redisKey, $expiration);
//Send an email with the token
$this->sendRequestPasswordResetEmail($user);
return $user;
}
/**
* Send an email to the user with the password token inside
*
* @param User $user
*/
private function sendRequestPasswordResetEmail(User $user)
{
$recipient = $user->getEmail();
$subject = $this->translator->trans("email.useraccount.resetpasswordrequest_subject");
$template = self::EMAIL_TEMPLATE_RESET_PASSWORD_REQUEST;
$token = $user->getLastPasswordToken();
$urlParams = Array(
"backboneroutes" => sprintf("%s/%s", $recipient, $token)
);
$reset_url = $this->router->generate("producteev_web_reset_password", $urlParams, true);
$params = array("token" => $token, "reset_url" => $reset_url, "fullname" => $user->getFullname());
$categories = array(self::EMAIL_CATEGORY_RESET_PASSWORD_REQUEST);
$this->emailManager->prepareAndSend($recipient, $subject, $template, $params, $categories);
}
/**
* Change the user password if the passwordToken is valid and if the newPassword respect rules and equals confirmation
*
* @param String $email
* @param String $passwordToken
* @param String $newPassword
* @param String $newPasswordConfirmation
* @return User $user
*/
public function resetPassword($email, $passwordToken, $newPassword, $newPasswordConfirmation)
{
//Check if the newPassword and the passwordConfirmation are equals
if ($newPassword != $newPasswordConfirmation) {
throw new InputInvalidException($this->translator->trans("core.inputinvalidexception.password_and_confirmation_not_equals"));
}
//Get the user by email address
$user = $this->objectManager->findOneByEmail($email);
if ($user == null) {
throw new InputInvalidException($this->translator->trans("core.inputinvalidexception.unknown_email_address", array("%email%" => $email)));
}
// check if the password token is valid by checking in redis store
$redisKey = $this->getPasswordTokenRedisKey($passwordToken);
if ($this->redisClient->get($redisKey) != $user->getId()) {
throw new InputInvalidException($this->translator->trans("core.inputinvalidexception.password_reset_unvalid_token"));
}
//set the new password and save it
$this->objectManager->setPassword($newPassword, $user);
$this->objectManager->persist($user);
//Remove the key in redis
$this->redisClient->del($redisKey);
//send an email to notify its password has changed
$this->sendPasswordResetConfirmationEmail($user);
return $user;
}
/**
* Send a confirmation email to the user saying that is password has changed
*
* @param User $user
*/
private function sendPasswordResetConfirmationEmail(User $user)
{
$recipient = $user->getEmail();
$subject = $this->translator->trans("email.useraccount.resetpasswordconfirmation_subject");
$params = array("user" => $user);
$categories = array(self::EMAIL_CATEGORY_RESET_PASSWORD_CONFIRMATION);
$template = self::EMAIL_TEMPLATE_RESET_PASSWORD_CONFIRMATION;
$this->emailManager->prepareAndSend($recipient, $subject, $template, $params, $categories);
}
public function getPasswordTokenRedisKey($passwordToken)
{
$redisKey = sprintf("%s%s", self::PASSWORD_TOKEN_REDIS_KEY_PREFIX, $passwordToken);
return $redisKey;
}
/**
* Change the user password
*
* @param User $user
* @param String $oldPassword
* @param String $newPassword
* @param String $newPasswordConfirmation
* @return User $user
*/
public function changePassword(User $user, $oldPassword, $newPassword, $newPasswordConfirmation)
{
$encodedOldPassword = $this->objectManager->encodePassword($user, $oldPassword);
if ($encodedOldPassword != $user->getPassword()) {
throw new InputInvalidException($this->translator->trans("core.inputinvalidexception.change_password_old_password_invalid"));
}
if ($newPassword != $newPasswordConfirmation) {
throw new InputInvalidException($this->translator->trans("core.inputinvalidexception.password_and_confirmation_different"));
}
$this->setPassword($newPassword, $user);
return $user;
}
/**
* Set the facebook id for the user
*
* @param User $user
*/
public function setFacebookId(User $user, $facebookId)
{
$this->objectManager->setFacebookId($user, $facebookId);
$this->objectManager->persist($user);
return $user;
}
/**
* Set the google id for the $user
*
* @param User $user
* @param string googleId
* @return User $user
*/
public function setGoogleId(User $user, $googleId)
{
$this->objectManager->setGoogleId($user, $googleId);
$this->objectManager->persist($user);
return $user;
}
/**
* Get a user by its facebook id
*
* @param User $user
* @param String $facebookId
* @return User $fbUser
* @todo Facebook OAuth should only be granted to our own api client
*/
public function getUserByFacebookId($facebookId)
{
$fbUser = $this->objectManager->findOneByFacebookId($facebookId);
return $fbUser;
}
/**
* Get a user by its google id
*
* @param User $user
* @param String $googleId
* @return User $googleUser
*/
public function getUserByGoogleId($googleId)
{
$googleUser = $this->objectManager->findOneByGoogleId($googleId);
return $googleUser;
}
/**
* Set the default project a $user
*
* @param User $user
* @param Project $defaultProject
* @return User $user
*/
public function setDefaultProject(User $user, Project $defaultProject)
{
$this->projectPrivacy->assertCanView($user, $defaultProject);
$this->objectManager->setDefaultProject($user, $defaultProject);
$this->objectManager->persist($user);
return $user;
}
/**
* Search users matching $search in $network (using the ngram method)
*
* @param User $user
* @param Network $network
* @param String $search
* @param integer $limit
* @return array<User> $usersFound
*/
public function searchUsersForNetwork(User $user, Network $network, $search, $limit = null, User $excludeUser = null)
{
$users = $network->getUsers();
$usersFound = array();
$i = 0;
foreach ($users as $user) {
if ($this->strSearchUtil->ngram($search, $user->getFullname()) && ($excludeUser === null || $user->getId() !== $excludeUser->getId())) {
$usersFound[ ] = $user;
if ($limit !== null && $i >= $limit-1) {
break;
}
$i++;
}
}
return $usersFound;
}
/**
* Find users with $fullname beginning with $search in $network
* Used by NlpUserParser
*
* @param User $user
* @param Network $network
* @param String $search
* @return array<User> $usersFound
* @todo improve this with elastic search
*/
public function searchUsersFullnameForNetwork(User $user, Network $network, $search)
{
$users = $network->getUsers();
$usersFound = array();
foreach ($users as $user) {
$found = true;
if (!empty($search)) {
$pos = mb_stripos($user->getFullname(), $search);
if ($pos !== false && $pos === 0) {
$usersFound[] = $user;
}
}
}
return $usersFound;
}
public function incrementUnreadNotifications(User $user)
{
$this->objectManager->incrementUnreadNotifications($user);
$this->objectManager->persist($user);
return $user;
}
public function decrementUnreadNotifications(User $user)
{
$this->objectManager->decrementUnreadNotifications($user);
$this->objectManager->persist($user);
return $user;
}
/**
* Find users with $search included in $users.fullname
*
* @param User $user
* @param Project $project
* @param String $search
* @param integer $limit
* @return array<User> $usersFound
*/
public function searchUserInRestrictedProject(User $user, Project $project, $search, $limit = null, User $excludeUser = null)
{
$users = $project->getRestrictedUsers();
$usersFound = array();
$i = 0;
foreach ($users as $user) {
if ($this->strSearchUtil->ngram($search, $user->getFullname()) && ($excludeUser === null || $user->getId() !== $excludeUser->getId())) {
$usersFound[] = $user;
if ($limit !== null && $i >= $limit-1) {
break;
}
$i++;
}
}
return $usersFound;
}
/*
* Send the account verification email to the $user email address
* Save the token in redis with an expiration time
*
*
* @param User $user
* @param bool $checkVerifiedSilent : don't throw an exception if the account is already verified
* @return void
*/
public function sendVerificationEmail(User $user, $checkVerifiedSilent = false)
{
if ($user->isVerified()) {
if (!$checkVerifiedSilent) {
throw new IntegrityConstraintException($this->translator->trans("core.integrityconstraintexception.user_account_already_verified"));
}
} else {
//generate the verification token
$token = $this->objectManager->generateVerificationToken($user);
//Save the key in redis with an expiration time
$redisKey = $this->getVerificationTokenRedisKey($token);
$this->redisClient->set($redisKey, $user->getId());
$expiration = $this->verificationTokenLifetime;
$this->redisClient->expire($redisKey, $expiration);
//Send an email with the token
$this->prepareAndSendVerificationEmail($user, $token);
}
}
private function getVerificationTokenRedisKey($verificationToken)
{
$redisKey = sprintf("%s%s", self::VERIFICATION_TOKEN_REDIS_KEY_PREFIX, $verificationToken);
return $redisKey;
}
/*
* Prepare and send the email to the $user email address including the link to verify the $user account
*
* @param User $user
* @param string $token
* @return void
*/
private function prepareAndSendVerificationEmail(User $user, $token)
{
$subjectParams = array(
"%user_fullname%" => $user->getFullname()
);
$subject = $this->translator->trans("email.useraccount.user_verification_subject", $subjectParams);
$emailAddress = $user->getEmail();
$urlParams = array(
"token" => $token,
"email" => $emailAddress
);
$verificationUrl = $this->router->generate("producteev_web_user_verification", $urlParams, true);
$templateParams = array(
"user_fullname" => $user->getFullname(),
"verification_url" => $verificationUrl
);
$categories = array(
"userVerification"
);
$template = "user.verification";
//send the email
$this->emailManager->prepareAndSend($emailAddress, $subject, $template, $templateParams, $categories);
}
/**
* Change the user password if the passwordToken is valid and if the newPassword respect rules and equals confirmation
*
* @param String $email
* @param String $verificationToken
* @return User $user
*/
public function verifyUserAccount($email, $verificationToken)
{
//Get the user by email address
$user = $this->objectManager->findOneByEmail($email);
if ($user == null) {
throw new InputInvalidException($this->translator->trans("core.inputinvalidexception.unknown_email_address", array("%email%" => $email)));
}
if ($user->isVerified()) {
throw new IntegrityConstraintException($this->translator->trans("core.integrityconstraintexception.user_account_already_verified"));
}
// check if the password token is valid by checking in redis store
$redisKey = $this->getVerificationTokenRedisKey($verificationToken);
if ($this->redisClient->get($redisKey) !== $user->getId()) {
throw new InputInvalidException($this->translator->trans("core.inputinvalidexception.user_verification_invalid_token"));
}
//switch the user account to verify and persist
$this->switchToVerified($user);
//Remove the key in redis
$this->redisClient->del($redisKey);
return $user;
}
/**
* Turn a $user account to verified
*
* @param User $user
* @return User $user
*/
public function switchToVerified(User $user)
{
if (!$user->isVerified()) {
$this->objectManager->switchToVerified($user);
$this->objectManager->persist($user);
//Send event user verified
$event = new UserEvent($user);
$this->eventDispatcher->dispatch(UserEvent::VERIFIED, $event);
}
return $user;
}
/**
* Turn a $user account to unverified
*
* @param User $user
* @return User $user
*/
public function switchToUnverified(User $user)
{
if ($user->isVerified()) {
$this->objectManager->switchToUnverified($user);
$this->objectManager->persist($user);
}
return $user;
}
/**
* Set the user date format
* @param User $user
* @param string $dateFormat
* @return User $user
*/
public function setDateFormat(User $user, $dateFormat)
{
$this->objectManager->setDateFormat($user, $dateFormat);
$this->objectManager->persist($user);
return $user;
}
public function searchByEmail(User $user, $search, $excludeLoggedInUser = true)
{
$networks = $this->networkService->findAllForUser($user);
$results = $this->objectManager->searchByEmailInNetworks($user, $networks, $search, $excludeLoggedInUser);
return $results;
}
public function setPasswordKnown(User $user)
{
$this->objectManager->setPasswordKnown($user);
$this->objectManager->persist($user);
return $user;
}
public function setPasswordUnknown(User $user)
{
$this->objectManager->setPasswordUnknown($user);
$this->objectManager->persist($user);
return $user;
}
}