|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Apps\Controller\Front; |
|
4
|
|
|
|
|
5
|
|
|
use Apps\ActiveRecord\Invite; |
|
6
|
|
|
use Apps\ActiveRecord\UserRecovery; |
|
7
|
|
|
use Apps\Model\Front\User\FormLogin; |
|
8
|
|
|
use Apps\Model\Front\User\FormPasswordChange; |
|
9
|
|
|
use Apps\Model\Front\User\FormRecovery; |
|
10
|
|
|
use Apps\Model\Front\User\FormRegister; |
|
11
|
|
|
use Apps\Model\Front\User\FormSocialAuth; |
|
12
|
|
|
use Extend\Core\Arch\FrontAppController; |
|
13
|
|
|
use Ffcms\Core\App; |
|
14
|
|
|
use Ffcms\Core\Exception\ForbiddenException; |
|
15
|
|
|
use Ffcms\Core\Exception\NativeException; |
|
16
|
|
|
use Ffcms\Core\Exception\NotFoundException; |
|
17
|
|
|
use Ffcms\Core\Exception\SyntaxException; |
|
18
|
|
|
use Ffcms\Core\Helper\Type\Any; |
|
19
|
|
|
use Ffcms\Core\Helper\Type\Obj; |
|
20
|
|
|
use Ffcms\Core\Helper\Type\Str; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class User - standard user controller: login/signup/logout/etc |
|
24
|
|
|
* @package Apps\Controller\Front |
|
25
|
|
|
*/ |
|
26
|
|
|
class User extends FrontAppController |
|
27
|
|
|
{ |
|
28
|
|
|
const EVENT_USER_LOGIN_SUCCESS = 'user.login.success'; |
|
29
|
|
|
const EVENT_USER_LOGIN_FAIL = 'user.login.fail'; |
|
30
|
|
|
const EVENT_USER_REGISTER_SUCCESS = 'user.signup.success'; |
|
31
|
|
|
const EVENT_USER_REGISTER_FAIL = 'user.signup.fail'; |
|
32
|
|
|
const EVENT_USER_RECOVERY_SUCCESS = 'user.recovery.success'; |
|
33
|
|
|
|
|
34
|
|
|
use User\ActionLogin { |
|
35
|
|
|
login as actionLogin; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
use User\ActionSignup { |
|
39
|
|
|
signup as actionSignup; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
use User\ActionSocialAuth { |
|
43
|
|
|
socialauth as actionSocialauth; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
use User\ActionRecovery { |
|
47
|
|
|
recovery as actionRecovery; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
use User\ActionApprove { |
|
51
|
|
|
approve as actionApprove; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Make logout if user is signIn |
|
56
|
|
|
* @throws ForbiddenException |
|
57
|
|
|
*/ |
|
58
|
|
|
public function actionLogout() |
|
59
|
|
|
{ |
|
60
|
|
|
// check if user authorized |
|
61
|
|
|
if (!App::$User->isAuth()) { |
|
62
|
|
|
throw new ForbiddenException(__('You are not authorized user')); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
// unset session data |
|
66
|
|
|
App::$Session->invalidate(); |
|
67
|
|
|
|
|
68
|
|
|
// redirect to main |
|
69
|
|
|
$this->response->redirect('/'); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|