|
@@ -2,8 +2,6 @@
|
|
|
|
|
|
namespace ForkBB\Models\Pages;
|
|
|
|
|
|
-use R2\DependencyInjection\ContainerInterface;
|
|
|
-
|
|
|
class Auth extends Page
|
|
|
{
|
|
|
/**
|
|
@@ -31,19 +29,19 @@ class Auth extends Page
|
|
|
*/
|
|
|
public function logout($args)
|
|
|
{
|
|
|
- $this->c->get('Lang')->load('login');
|
|
|
+ $this->c->Lang->load('login');
|
|
|
|
|
|
- if ($this->c->get('Csrf')->verify($args['token'], 'Logout', $args)) {
|
|
|
- $user = $this->c->get('user');
|
|
|
+ if ($this->c->Csrf->verify($args['token'], 'Logout', $args)) {
|
|
|
+ $user = $this->c->user;
|
|
|
|
|
|
- $this->c->get('UserCookie')->deleteUserCookie();
|
|
|
- $this->c->get('Online')->delete($user);
|
|
|
- $this->c->get('UserMapper')->updateLastVisit($user);
|
|
|
+ $this->c->UserCookie->deleteUserCookie();
|
|
|
+ $this->c->Online->delete($user);
|
|
|
+ $this->c->UserMapper->updateLastVisit($user);
|
|
|
|
|
|
- return $this->c->get('Redirect')->setPage('Index')->setMessage(__('Logout redirect'));
|
|
|
+ return $this->c->Redirect->setPage('Index')->setMessage(__('Logout redirect'));
|
|
|
}
|
|
|
|
|
|
- return $this->c->get('Redirect')->setPage('Index')->setMessage(__('Bad token'));
|
|
|
+ return $this->c->Redirect->setPage('Index')->setMessage(__('Bad token'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -53,14 +51,14 @@ class Auth extends Page
|
|
|
*/
|
|
|
public function login(array $args)
|
|
|
{
|
|
|
- $this->c->get('Lang')->load('login');
|
|
|
+ $this->c->Lang->load('login');
|
|
|
|
|
|
if (! isset($args['_username'])) {
|
|
|
$args['_username'] = '';
|
|
|
}
|
|
|
if (! isset($args['_redirect'])) {
|
|
|
$args['_redirect'] = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
|
|
|
- $args['_redirect'] = $this->c->get('Router')->validate($args['_redirect'], 'Index');
|
|
|
+ $args['_redirect'] = $this->c->Router->validate($args['_redirect'], 'Index');
|
|
|
}
|
|
|
|
|
|
$this->titles = [
|
|
@@ -68,11 +66,11 @@ class Auth extends Page
|
|
|
];
|
|
|
$this->data = [
|
|
|
'username' => $args['_username'],
|
|
|
- 'formAction' => $this->c->get('Router')->link('Login'),
|
|
|
- 'formToken' => $this->c->get('Csrf')->create('Login'),
|
|
|
- 'forgetLink' => $this->c->get('Router')->link('Forget'),
|
|
|
+ 'formAction' => $this->c->Router->link('Login'),
|
|
|
+ 'formToken' => $this->c->Csrf->create('Login'),
|
|
|
+ 'forgetLink' => $this->c->Router->link('Forget'),
|
|
|
'regLink' => $this->config['o_regs_allow'] == '1'
|
|
|
- ? $this->c->get('Router')->link('Registration')
|
|
|
+ ? $this->c->Router->link('Registration')
|
|
|
: null,
|
|
|
'formRedirect' => $args['_redirect'],
|
|
|
'formSave' => ! empty($args['_save'])
|
|
@@ -87,9 +85,9 @@ class Auth extends Page
|
|
|
*/
|
|
|
public function loginPost()
|
|
|
{
|
|
|
- $this->c->get('Lang')->load('login');
|
|
|
+ $this->c->Lang->load('login');
|
|
|
|
|
|
- $v = $this->c->get('Validator');
|
|
|
+ $v = $this->c->Validator;
|
|
|
$v->setRules([
|
|
|
'token' => 'token:Login',
|
|
|
'redirect' => 'referer:Index',
|
|
@@ -108,7 +106,7 @@ class Auth extends Page
|
|
|
}
|
|
|
|
|
|
if ($ok) {
|
|
|
- return $this->c->get('Redirect')->setUrl($data['redirect'])->setMessage(__('Login redirect'));
|
|
|
+ return $this->c->Redirect->setUrl($data['redirect'])->setMessage(__('Login redirect'));
|
|
|
} else {
|
|
|
return $this->login([
|
|
|
'_username' => $data['username'],
|
|
@@ -127,7 +125,7 @@ class Auth extends Page
|
|
|
*/
|
|
|
protected function loginProcess($username, $password, $save)
|
|
|
{
|
|
|
- $user = $this->c->get('UserMapper')->getUser($username, 'username');
|
|
|
+ $user = $this->c->UserMapper->getUser($username, 'username');
|
|
|
if (null == $user) {
|
|
|
return false;
|
|
|
}
|
|
@@ -138,7 +136,7 @@ class Auth extends Page
|
|
|
|
|
|
// For FluxBB by Visman 1.5.10.74 and above
|
|
|
if (strlen($hash) == 40) {
|
|
|
- if (hash_equals($hash, sha1($password . $this->c->getParameter('SALT1')))) {
|
|
|
+ if (hash_equals($hash, sha1($password . $this->c->SALT1))) {
|
|
|
$hash = password_hash($password, PASSWORD_DEFAULT);
|
|
|
$update['password'] = $hash;
|
|
|
$authorized = true;
|
|
@@ -159,19 +157,19 @@ class Auth extends Page
|
|
|
// перезаписываем ip админа и модератора - Visman
|
|
|
if ($user->isAdmMod
|
|
|
&& $this->config['o_check_ip']
|
|
|
- && $user->registrationIp != $this->c->get('user')->ip
|
|
|
+ && $user->registrationIp != $this->c->user->ip
|
|
|
) {
|
|
|
- $update['registration_ip'] = $this->c->get('user')->ip;
|
|
|
+ $update['registration_ip'] = $this->c->user->ip;
|
|
|
}
|
|
|
|
|
|
// изменения юзера в базе
|
|
|
- $this->c->get('UserMapper')->updateUser($user->id, $update);
|
|
|
+ $this->c->UserMapper->updateUser($user->id, $update);
|
|
|
// обновления кэша
|
|
|
if (isset($update['group_id'])) {
|
|
|
- $this->c->get('users_info update');
|
|
|
+ $this->c->{'users_info update'};
|
|
|
}
|
|
|
- $this->c->get('Online')->delete($this->c->get('user'));
|
|
|
- $this->c->get('UserCookie')->setUserCookie($user->id, $hash, $save);
|
|
|
+ $this->c->Online->delete($this->c->user);
|
|
|
+ $this->c->UserCookie->setUserCookie($user->id, $hash, $save);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -183,7 +181,7 @@ class Auth extends Page
|
|
|
*/
|
|
|
public function forget(array $args)
|
|
|
{
|
|
|
- $this->c->get('Lang')->load('login');
|
|
|
+ $this->c->Lang->load('login');
|
|
|
|
|
|
$this->nameTpl = 'login/forget';
|
|
|
$this->onlinePos = 'forget';
|
|
@@ -197,8 +195,8 @@ class Auth extends Page
|
|
|
];
|
|
|
$this->data = [
|
|
|
'email' => $args['_email'],
|
|
|
- 'formAction' => $this->c->get('Router')->link('Forget'),
|
|
|
- 'formToken' => $this->c->get('Csrf')->create('Forget'),
|
|
|
+ 'formAction' => $this->c->Router->link('Forget'),
|
|
|
+ 'formToken' => $this->c->Csrf->create('Forget'),
|
|
|
];
|
|
|
|
|
|
return $this;
|
|
@@ -210,9 +208,9 @@ class Auth extends Page
|
|
|
*/
|
|
|
public function forgetPost()
|
|
|
{
|
|
|
- $this->c->get('Lang')->load('login');
|
|
|
+ $this->c->Lang->load('login');
|
|
|
|
|
|
- $v = $this->c->get('Validator');
|
|
|
+ $v = $this->c->Validator;
|
|
|
$v->setRules([
|
|
|
'token' => 'token:Forget',
|
|
|
'email' => 'required|email',
|
|
@@ -224,7 +222,7 @@ class Auth extends Page
|
|
|
$data = $v->getData();
|
|
|
$this->iswev = $v->getErrors();
|
|
|
|
|
|
- if ($ok && ($user = $this->c->get('UserMapper')->getUser($data['email'], 'email')) === null) {
|
|
|
+ if ($ok && ($user = $this->c->UserMapper->getUser($data['email'], 'email')) === null) {
|
|
|
$this->iswev['v'][] = __('Invalid email');
|
|
|
$ok = false;
|
|
|
}
|
|
@@ -239,20 +237,20 @@ class Auth extends Page
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- $mail = $this->c->get('Mail');
|
|
|
- $mail->setFolder($this->c->getParameter('DIR_LANG'))
|
|
|
+ $mail = $this->c->Mail;
|
|
|
+ $mail->setFolder($this->c->DIR_LANG)
|
|
|
->setLanguage($user->language);
|
|
|
|
|
|
- $key = 'p' . $this->c->get('Secury')->randomPass(75);
|
|
|
- $hash = $this->c->get('Secury')->hash($data['email'] . $key);
|
|
|
- $link = $this->c->get('Router')->link('ChangePassword', ['email' => $data['email'], 'key' => $key, 'hash' => $hash]);
|
|
|
+ $key = 'p' . $this->c->Secury->randomPass(75);
|
|
|
+ $hash = $this->c->Secury->hash($data['email'] . $key);
|
|
|
+ $link = $this->c->Router->link('ChangePassword', ['email' => $data['email'], 'key' => $key, 'hash' => $hash]);
|
|
|
$tplData = ['link' => $link];
|
|
|
|
|
|
if ($mail->send($data['email'], 'change_password.tpl', $tplData)) {
|
|
|
- $this->c->get('UserMapper')->updateUser($user->id, ['activate_string' => $key, 'last_email_sent' => time()]);
|
|
|
- return $this->c->get('Message')->message(__('Forget mail', $this->config['o_admin_email']), false, 200);
|
|
|
+ $this->c->UserMapper->updateUser($user->id, ['activate_string' => $key, 'last_email_sent' => time()]);
|
|
|
+ return $this->c->Message->message(__('Forget mail', $this->config['o_admin_email']), false, 200);
|
|
|
} else {
|
|
|
- return $this->c->get('Message')->message(__('Error mail', $this->config['o_admin_email']), true, 200);
|
|
|
+ return $this->c->Message->message(__('Error mail', $this->config['o_admin_email']), true, 200);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -270,26 +268,26 @@ class Auth extends Page
|
|
|
unset($args['_ok']);
|
|
|
} else {
|
|
|
// что-то пошло не так
|
|
|
- if (! hash_equals($args['hash'], $this->c->get('Secury')->hash($args['email'] . $args['key']))
|
|
|
- || ! $this->c->get('Mail')->valid($args['email'])
|
|
|
- || ($user = $this->c->get('UserMapper')->getUser($args['email'], 'email')) === null
|
|
|
+ if (! hash_equals($args['hash'], $this->c->Secury->hash($args['email'] . $args['key']))
|
|
|
+ || ! $this->c->Mail->valid($args['email'])
|
|
|
+ || ($user = $this->c->UserMapper->getUser($args['email'], 'email')) === null
|
|
|
|| empty($user->activateString)
|
|
|
|| $user->activateString{0} !== 'p'
|
|
|
|| ! hash_equals($user->activateString, $args['key'])
|
|
|
) {
|
|
|
- return $this->c->get('Message')->message(__('Bad request'), false);
|
|
|
+ return $this->c->Message->message(__('Bad request'), false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $this->c->get('Lang')->load('login');
|
|
|
- $this->c->get('Lang')->load('profile');
|
|
|
+ $this->c->Lang->load('login');
|
|
|
+ $this->c->Lang->load('profile');
|
|
|
|
|
|
$this->titles = [
|
|
|
__('Change pass'),
|
|
|
];
|
|
|
$this->data = [
|
|
|
- 'formAction' => $this->c->get('Router')->link('ChangePassword', $args),
|
|
|
- 'formToken' => $this->c->get('Csrf')->create('ChangePassword', $args),
|
|
|
+ 'formAction' => $this->c->Router->link('ChangePassword', $args),
|
|
|
+ 'formToken' => $this->c->Csrf->create('ChangePassword', $args),
|
|
|
];
|
|
|
|
|
|
return $this;
|
|
@@ -302,22 +300,22 @@ class Auth extends Page
|
|
|
*/
|
|
|
public function changePassPost(array $args)
|
|
|
{
|
|
|
- $this->c->get('Lang')->load('login');
|
|
|
+ $this->c->Lang->load('login');
|
|
|
|
|
|
// что-то пошло не так
|
|
|
- if (! hash_equals($args['hash'], $this->c->get('Secury')->hash($args['email'] . $args['key']))
|
|
|
- || ! $this->c->get('Mail')->valid($args['email'])
|
|
|
- || ($user = $this->c->get('UserMapper')->getUser($args['email'], 'email')) === null
|
|
|
+ if (! hash_equals($args['hash'], $this->c->Secury->hash($args['email'] . $args['key']))
|
|
|
+ || ! $this->c->Mail->valid($args['email'])
|
|
|
+ || ($user = $this->c->UserMapper->getUser($args['email'], 'email')) === null
|
|
|
|| empty($user->activateString)
|
|
|
|| $user->activateString{0} !== 'p'
|
|
|
|| ! hash_equals($user->activateString, $args['key'])
|
|
|
) {
|
|
|
- return $this->c->get('Message')->message(__('Bad request'), false);
|
|
|
+ return $this->c->Message->message(__('Bad request'), false);
|
|
|
}
|
|
|
|
|
|
- $this->c->get('Lang')->load('profile');
|
|
|
+ $this->c->Lang->load('profile');
|
|
|
|
|
|
- $v = $this->c->get('Validator');
|
|
|
+ $v = $this->c->Validator;
|
|
|
$v->setRules([
|
|
|
'token' => 'token:ChangePassword',
|
|
|
'password' => ['required|string|min:8', __('New pass')],
|
|
@@ -335,9 +333,9 @@ class Auth extends Page
|
|
|
}
|
|
|
$data = $v->getData();
|
|
|
|
|
|
- $this->c->get('UserMapper')->updateUser($user->id, ['password' => password_hash($data['password'], PASSWORD_DEFAULT), 'activate_string' => null]);
|
|
|
+ $this->c->UserMapper->updateUser($user->id, ['password' => password_hash($data['password'], PASSWORD_DEFAULT), 'activate_string' => null]);
|
|
|
|
|
|
$this->iswev['s'][] = __('Pass updated');
|
|
|
- return $this->login(['_redirect' => $this->c->get('Router')->link('Index')]);
|
|
|
+ return $this->login(['_redirect' => $this->c->Router->link('Index')]);
|
|
|
}
|
|
|
}
|