| @@ 486-496 (lines=11) @@ | ||
| 483 | $userId = $this->userSession->getUser()->getUID(); |
|
| 484 | $user = $this->userManager->get($id); |
|
| 485 | ||
| 486 | if($userId === $id) { |
|
| 487 | return new DataResponse( |
|
| 488 | [ |
|
| 489 | 'status' => 'error', |
|
| 490 | 'data' => [ |
|
| 491 | 'message' => (string)$this->l10n->t('Unable to delete user.') |
|
| 492 | ] |
|
| 493 | ], |
|
| 494 | Http::STATUS_FORBIDDEN |
|
| 495 | ); |
|
| 496 | } |
|
| 497 | ||
| 498 | if(!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) { |
|
| 499 | return new DataResponse( |
|
| @@ 575-585 (lines=11) @@ | ||
| 572 | ); |
|
| 573 | } |
|
| 574 | ||
| 575 | if(!$user){ |
|
| 576 | return new DataResponse( |
|
| 577 | [ |
|
| 578 | 'status' => 'error', |
|
| 579 | 'data' => [ |
|
| 580 | 'message' => (string)$this->l10n->t('Invalid user') |
|
| 581 | ] |
|
| 582 | ], |
|
| 583 | Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 584 | ); |
|
| 585 | } |
|
| 586 | ||
| 587 | // this is the only permission a backend provides and is also used |
|
| 588 | // for the permission of setting a email address |
|
| @@ 589-599 (lines=11) @@ | ||
| 586 | ||
| 587 | // this is the only permission a backend provides and is also used |
|
| 588 | // for the permission of setting a email address |
|
| 589 | if(!$user->canChangeDisplayName()){ |
|
| 590 | return new DataResponse( |
|
| 591 | [ |
|
| 592 | 'status' => 'error', |
|
| 593 | 'data' => [ |
|
| 594 | 'message' => (string)$this->l10n->t('Unable to change mail address') |
|
| 595 | ] |
|
| 596 | ], |
|
| 597 | Http::STATUS_FORBIDDEN |
|
| 598 | ); |
|
| 599 | } |
|
| 600 | ||
| 601 | // admins can set email without verification |
|
| 602 | if ($mailAddress === '' || $this->isAdmin) { |
|
| @@ 628-640 (lines=13) @@ | ||
| 625 | ], |
|
| 626 | Http::STATUS_OK |
|
| 627 | ); |
|
| 628 | } else { |
|
| 629 | return new DataResponse( |
|
| 630 | [ |
|
| 631 | 'status' => 'error', |
|
| 632 | 'data' => [ |
|
| 633 | 'username' => $id, |
|
| 634 | 'mailAddress' => $mailAddress, |
|
| 635 | 'message' => (string) $this->l10n->t('No email was sent because you already sent one recently. Please try again later.') |
|
| 636 | ] |
|
| 637 | ], |
|
| 638 | Http::STATUS_OK |
|
| 639 | ); |
|
| 640 | } |
|
| 641 | ||
| 642 | } catch (\Exception $e){ |
|
| 643 | return new DataResponse( |
|
| @@ 736-744 (lines=9) @@ | ||
| 733 | 'displayName' => $displayName, |
|
| 734 | ], |
|
| 735 | ]); |
|
| 736 | } else { |
|
| 737 | return new DataResponse([ |
|
| 738 | 'status' => 'error', |
|
| 739 | 'data' => [ |
|
| 740 | 'message' => $this->l10n->t('Unable to change full name'), |
|
| 741 | 'displayName' => $user->getDisplayName(), |
|
| 742 | ], |
|
| 743 | ]); |
|
| 744 | } |
|
| 745 | } |
|
| 746 | ||
| 747 | /** |
|
| @@ 894-904 (lines=11) @@ | ||
| 891 | } |
|
| 892 | ||
| 893 | ||
| 894 | if(!$user){ |
|
| 895 | return new DataResponse( |
|
| 896 | array( |
|
| 897 | 'status' => 'error', |
|
| 898 | 'data' => array( |
|
| 899 | 'message' => (string)$this->l10n->t('Invalid user') |
|
| 900 | ) |
|
| 901 | ), |
|
| 902 | Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 903 | ); |
|
| 904 | } |
|
| 905 | ||
| 906 | ||
| 907 | $value = filter_var($enabled, FILTER_VALIDATE_BOOLEAN); |
|
| @@ 908-919 (lines=12) @@ | ||
| 905 | ||
| 906 | ||
| 907 | $value = filter_var($enabled, FILTER_VALIDATE_BOOLEAN); |
|
| 908 | if(!isset($value) || is_null($value)) |
|
| 909 | { |
|
| 910 | return new DataResponse( |
|
| 911 | array( |
|
| 912 | 'status' => 'error', |
|
| 913 | 'data' => array( |
|
| 914 | 'message' => (string)$this->l10n->t('Unable to enable/disable user.') |
|
| 915 | ) |
|
| 916 | ), |
|
| 917 | Http::STATUS_FORBIDDEN |
|
| 918 | ); |
|
| 919 | } |
|
| 920 | ||
| 921 | $user->setEnabled($value); |
|
| 922 | ||
| @@ 602-613 (lines=12) @@ | ||
| 599 | } |
|
| 600 | ||
| 601 | // admins can set email without verification |
|
| 602 | if ($mailAddress === '' || $this->isAdmin) { |
|
| 603 | $this->setEmailAddress($userId, $mailAddress); |
|
| 604 | return new DataResponse( |
|
| 605 | [ |
|
| 606 | 'status' => 'success', |
|
| 607 | 'data' => [ |
|
| 608 | 'message' => (string)$this->l10n->t('Email has been changed successfully.') |
|
| 609 | ] |
|
| 610 | ], |
|
| 611 | Http::STATUS_OK |
|
| 612 | ); |
|
| 613 | } |
|
| 614 | ||
| 615 | try { |
|
| 616 | if ($this->sendEmail($userId, $mailAddress)) { |
|