Passed
Pull Request — developer (#318)
by Arkadiusz
87:16 queued 52:35
created

PasswordChangeModal::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
/**
3
 * Password change modal action file.
4
 *
5
 * @package Action
6
 *
7
 * @copyright YetiForce Sp. z o.o.
8
 * @license   YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Arkadiusz Sołek <[email protected]>
10
 */
11
12
namespace YF\Modules\Users\Action;
13
14
/**
15
 * Password change modal action class.
16
 */
17
class PasswordChangeModal extends \App\Controller\Action
18
{
19
	/** {@inheritdoc} */
20
	public function checkPermission(): void
21
	{
22
	}
23
24
	/** {@inheritdoc} */
25
	public function process()
26
	{
27
		$response = new \App\Response();
28
		$changePassword = \App\Api::getInstance()->call('Users/ChangePassword', [
29
			'currentPassword' => $this->request->getRaw('oldPassword'),
30
			'newPassword' => $this->request->getRaw('password'),
31
		], 'put');
32
		if ($changePassword) {
33
			$response->setResult(\App\Language::translate('LBL_PASSWORD_CHANGED', 'Users'));
34
		} else {
35
			$response->setError(\App\Language::translate('LBL_FAILED_PASSWORD_CHANGED', 'Users'));
36
		}
37
		$response->emit();
38
	}
39
}
40