Update Login, Registration and Mail send page for log

This commit is contained in:
Visman 2021-01-19 21:32:30 +07:00
parent 1040e9972d
commit a28e4552fe
3 changed files with 62 additions and 10 deletions

View file

@ -74,10 +74,6 @@ class Auth extends Page
if ($v->validation($_POST, true)) {
$this->loginEnd($v);
$this->c->Log->info('Login', [
'user' => $this->userAfterLogin->fLog(),
]);
return $this->c->Redirect->url($v->redirect)->message('Login redirect');
}
@ -123,6 +119,12 @@ class Auth extends Page
$this->c->Online->delete($this->user);
$this->c->Cookie->setUser($this->userAfterLogin, (bool) $v->save);
$this->c->Log->info('Login', [
'user' => $this->userAfterLogin->fLog(),
'form' => $v->getData(false, ['token', 'password']),
'headers' => true,
]);
}
/**
@ -229,8 +231,9 @@ class Auth extends Page
$v = $this->c->Test->beforeValidation($v);
$isValid = $v->validation($_POST, true);
$context = [
'user' => $this->user->fLog(), // ???? Guest only?
'form' => $v->getData(false, ['token']),
'user' => $this->user->fLog(), // ???? Guest only?
'form' => $v->getData(false, ['token']),
'headers' => true,
];
if ($isValid) {

View file

@ -30,13 +30,19 @@ class Email extends Page
{
$this->curUser = $this->c->users->load((int) $args['id']);
if (! $this->curUser instanceof User || $this->curUser->isGuest) {
if (
! $this->curUser instanceof User
|| $this->curUser->isGuest
) {
return $this->c->Message->message('Bad request');
}
$rules = $this->c->ProfileRules->setUser($this->curUser);
if (! $rules->viewEmail || ! $rules->sendEmail) {
if (
! $rules->viewEmail
|| ! $rules->sendEmail
) {
$message = null === $rules->sendEmail ? 'Form email disabled' : 'Bad request';
return $this->c->Message->message($message);
@ -86,9 +92,19 @@ class Email extends Page
$this->c->users->update($this->user);
}
$this->c->Log->info('Email sent', [
'user' => $this->user->fLog(),
'recipient' => $this->curUser->fLog(),
]);
return $this->c->Redirect->url($v->redirect)->message('Email sent redirect');
}
} catch (MailException $e) {
$this->c->Log->error('Email send MailException', [
'user' => $this->user->fLog(),
'exception' => $e,
'headers' => false,
]);
}
return $this->c->Message->message('When sending email there was an error');
@ -96,6 +112,11 @@ class Email extends Page
$this->fIswev = $v->getErrors();
$data = $v->getData();
$this->c->Log->warning('Email send form failed', [
'user' => $this->user->fLog(),
'recipient' => $this->curUser->fLog(),
]);
}
$this->nameTpl = 'email';

View file

@ -59,6 +59,11 @@ class Register extends Page
$this->fIswev = $v->getErrors();
$this->c->Log->warning('Registration failed', [
'user' => $this->user->fLog(),
'form' => $v->getData(false, ['token', 'password']),
]);
// нет согласия с правилами
if (isset($this->fIswev['cancel'])) {
return $this->c->Message->message('Reg cancel', true, 403);
@ -165,6 +170,12 @@ class Register extends Page
$newUserId = $this->c->users->insert($user);
$this->c->Log->info('Registriaton', [
'user' => $user->fLog(),
'form' => $v->getData(false, ['token', 'password']),
'headers' => true,
]);
// уведомление о регистрации
if (
'1' == $this->c->config->o_regs_report
@ -197,7 +208,11 @@ class Register extends Page
->setTpl('new_user.tpl', $tplData)
->send();
} catch (MailException $e) {
//????
$this->c->Log->error('Registration notification to admins MailException', [
'user' => $user->fLog(),
'exception' => $e,
'headers' => false,
]);
}
}
@ -234,7 +249,11 @@ class Register extends Page
->setTpl('welcome.tpl', $tplData)
->send();
} catch (MailException $e) {
$isSent = false;
$this->c->Log->error('Registration activation email MailException', [
'user' => $user->fLog(),
'exception' => $e,
'headers' => false,
]);
}
// письмо активации аккаунта отправлено
@ -268,6 +287,11 @@ class Register extends Page
|| empty($user->activate_string)
|| ! \hash_equals($user->activate_string, $args['key'])
) {
$this->c->Log->warning('Account activation failed', [
'user' => $user instanceof User ? $user->fLog() : $this->user->fLog(),
'args' => $args,
]);
return $this->c->Message->message('Bad request', false);
}
@ -277,6 +301,10 @@ class Register extends Page
$this->c->users->update($user);
$this->c->Log->info('Account activated', [
'user' => $user->fLog(),
]);
$this->c->Lang->load('register');
$auth = $this->c->Auth;