Passed
Pull Request — master (#11)
by Anton
03:24
created

Recover::handle()   B

Complexity

Conditions 6
Paths 8

Size

Total Lines 27
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.439
c 0
b 0
f 0
cc 6
eloc 8
nc 8
nop 0
1
<?php
2
3
namespace Modules\Auth\Action {
4
5
	use Modules\Auth, Request;
6
7
	class Recover extends Auth\Utils\Action {
8
9
		# Handle request
10
11
		public function handle() {
12
13
			# Init user by secret code
14
15
			if (false !== ($code = Auth::secret())) $this->code = $code;
16
17
			else Request::redirect(INSTALL_PATH . (Auth::admin() ? '/admin' : '/profile') . '/reset');
18
19
			# Set view
20
21
			$this->view = (Auth::admin() ? 'Blocks/Auth/Recover' : 'Blocks/Profile/Auth/Recover');
22
23
			# Create form
24
25
			$this->form = new Auth\Form\Recover;
26
27
			# Handle form
28
29
			if ($this->form->handle(new Auth\Controller\Recover)) {
30
31
				Request::redirect(INSTALL_PATH . (Auth::admin() ? '/admin' : '/profile') . '/login?submitted=recover');
32
			}
33
34
			# ------------------------
35
36
			return $this->getContents();
37
		}
38
	}
39
}
40