1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-28 20:45:00 +03:00

reactivation

This commit is contained in:
Igor Khohlov 2012-06-13 11:46:40 +03:00
parent 7c3afec126
commit 869bd577fa
9 changed files with 242 additions and 84 deletions

View file

@ -44,9 +44,11 @@ class ActionLogin extends Action {
$this->AddEvent('index','EventLogin');
$this->AddEvent('exit','EventExit');
$this->AddEvent('reminder','EventReminder');
$this->AddEvent('reactivation','EventReactivation');
$this->AddEvent('ajax-login','EventAjaxLogin');
$this->AddEvent('ajax-reminder','EventAjaxReminder');
$this->AddEvent('ajax-reactivation','EventAjaxReactivation');
}
/**
* Ajax авторизация
@ -70,7 +72,12 @@ class ActionLogin extends Action {
/**
* Сверяем хеши паролей и проверяем активен ли юзер
*/
if ($oUser->getPassword()==func_encrypt(getRequest('password')) and $oUser->getActivate()) {
if ($oUser->getPassword()==func_encrypt(getRequest('password'))) {
if (!$oUser->getActivate()) {
$this->Message_AddErrorSingle($this->Lang_Get('user_not_activated', array('reactivation_path' => Router::GetPath('login') . 'reactivation')));
return;
}
$bRemember=getRequest('remember',false) ? true : false;
/**
* Авторизуем
@ -89,6 +96,44 @@ class ActionLogin extends Action {
}
$this->Message_AddErrorSingle($this->Lang_Get('user_login_bad'));
}
/**
* Повторный запрос активации
*/
protected function EventReactivation()
{
if($this->User_GetUserCurrent()) {
Router::Location(Config::Get('path.root.web').'/');
}
$this->Viewer_AddHtmlTitle($this->Lang_Get('reactivation'));
}
/**
* Ajax повторной активации
*/
protected function EventAjaxReactivation()
{
$this->Viewer_SetResponseAjax('json');
if ((func_check(getRequest('mail'), 'mail') and $oUser = $this->User_GetUserByMail(getRequest('mail')))) {
if ($oUser->getActivate()) {
$this->Message_AddErrorSingle($this->Lang_Get('registration_activate_error_reactivate'));
return;
} else {
$oUser->setActivateKey(md5(func_generator() . time()));
if ($this->User_Update($oUser)) {
$this->Message_AddNotice($this->Lang_Get('reactivation_send_link'));
$this->Notify_SendReactivationCode($oUser);
return;
}
}
}
$this->Message_AddErrorSingle($this->Lang_Get('password_reminder_bad_email'));
}
/**
* Обрабатываем процесс залогинивания
* По факту только отображение шаблона, дальше вступает в дело Ajax

View file

@ -236,6 +236,30 @@ class ModuleNotify extends Module {
$this->Mail_Send();
}
}
/**
* Отправляет уведомление с новым линком активации
*
* @param ModuleUser_EntityUser $oUser
*/
public function SendReactivationCode(ModuleUser_EntityUser $oUser) {
/**
* Передаём в шаблон переменные
*/
$this->oViewerLocal->Assign('oUser',$oUser);
/**
* Формируем шаблон
*/
$sBody=$this->oViewerLocal->Fetch($this->GetTemplatePath('notify.reactivation.tpl'));
/**
* Отправляем мыло
*/
$this->Mail_SetAdress($oUser->getMail(),$oUser->getLogin());
$this->Mail_SetSubject($this->Lang_Get('notify_subject_reactvation'));
$this->Mail_SetBody($sBody);
$this->Mail_setHTML();
$this->Mail_Send();
}
/**
* Отправляет уведомление при регистрации с активацией

View file

@ -51,6 +51,7 @@ class ModuleUser_MapperUser extends Mapper {
user_rating = ? ,
user_count_vote = ? ,
user_activate = ? ,
user_activate_key = ? ,
user_profile_name = ? ,
user_profile_sex = ? ,
user_profile_country = ? ,
@ -76,6 +77,7 @@ class ModuleUser_MapperUser extends Mapper {
$oUser->getRating(),
$oUser->getCountVote(),
$oUser->getActivate(),
$oUser->getActivateKey(),
$oUser->getProfileName(),
$oUser->getProfileSex(),
$oUser->getProfileCountry(),

View file

@ -423,6 +423,35 @@ ls.user = (function ($) {
});
};
/**
* Ajax запрос на ссылку активации
* @param form
*/
this.reminder = function(form) {
var url = aRouter.login+'ajax-reactivation/';
ls.hook.marker('reactivationBefore');
ls.ajaxSubmit(url, form, function(result) {
if (typeof(form)=='string') {
form=$('#'+form);
}
form.find('.validate-error-show').removeClass('validate-error-show').addClass('validate-error-hide');
if (result.bStateError) {
form.find('.validate-error-reactivation').removeClass('validate-error-hide').addClass('validate-error-show').text(result.sMsg);
} else {
form.find('input').val('');
if (result.sMsg) {
ls.msg.notice(null,result.sMsg);
}
if (result.sUrlRedirect) {
window.location=result.sUrlRedirect;
}
ls.hook.run('ls_user_reactivation_after', [form, result]);
}
});
};
/**
* Поиск пользователей
*/

View file

@ -412,6 +412,7 @@ return array(
'user_login_submit' => 'Login',
'user_login_remember' => 'Remember me',
'user_login_bad' => 'Something is wrong! Wrong login (e-mail) or password?.',
'user_not_activated' => 'You have not activated your account. <br/> <a href="%%reactivation_path%%">Re-activation request</a>',
'user_password' => 'Password',
'user_password_reminder' => 'Password reminder',
'user_exit_notice' => 'Please come again.',
@ -499,6 +500,12 @@ return array(
'registration_captcha_error' => 'Wrong code',
'registration_submit' => 'Submit registration',
'registration_ok' => 'Congratulation with successful registration!',
/**
* Re-activation
*/
"reactivation" => "Re-activation request",
"reactivation_submit" => "Get a link to the activation",
"reactivation_send_link" => "Activation link is sent to your e-mail.",
/**
* Vote for users
*/
@ -959,6 +966,7 @@ return array(
'notify_subject_reminder_password' => 'New password',
'notify_subject_wall_reply' => 'You\'ve recieved reply to your post on wall',
'notify_subject_wall_new' => 'You\'ve recieved new post on your wall',
'notify_subject_reactvation' => 'Re-activation request',
/**
* Админка
*/

View file

@ -412,6 +412,7 @@ return array(
'user_login_submit' => 'Войти',
'user_login_remember' => 'Запомнить меня',
'user_login_bad' => 'Что-то не так! Вероятно, неправильно указан логин (e-mail) или пароль.',
'user_not_activated' => 'Вы не активировали вашу учетную запись. <br/> <a href="%%reactivation_path%%">Повторный запрос активации</a>',
'user_password' => 'Пароль',
'user_password_reminder' => 'Напомнить пароль',
'user_exit_notice' => 'Обязательно приходите еще.',
@ -499,6 +500,14 @@ return array(
'registration_captcha_error' => 'Неверный код',
'registration_submit' => 'Зарегистрироваться',
'registration_ok' => 'Поздравляем! Регистрация прошла успешно',
/**
* Повторный запрос активации
*/
"reactivation" => "Повторный запрос активации",
"reactivation_submit" => "Получить ссылку на активацию",
"reactivation_send_link" => "Ссылка для активации отправлена на ваш адрес электронной почты.",
/**
* Голосование за пользователя
*/
@ -959,6 +968,7 @@ return array(
'notify_subject_reminder_password' => 'Новый пароль',
'notify_subject_wall_reply' => 'Ответ на ваше сообщение на стене',
'notify_subject_wall_new' => 'Новое сообщение на вашей стене',
'notify_subject_reactvation' => 'Повторный запрос активации',
/**
* Админка
*/

View file

@ -0,0 +1,26 @@
{assign var="noSidebar" value=true}
{include file='header.tpl'}
<script type="text/javascript">
jQuery(document).ready(function($){
$('#reactivation-form').bind('submit',function(){
ls.user.reminder('reactivation-form');
return false;
});
$('#reactivation-form-submit').attr('disabled',false);
});
</script>
<h2 class="page-header">{$aLang.reactivation}</h2>
<form action="{router page='login'}reactivation/" method="POST" id="reactivation-form">
<p><label for="reactivation-mail">{$aLang.password_reminder_email}</label>
<input type="text" name="mail" id="reactivation-mail" class="input-text input-width-200" />
<small class="validate-error-hide validate-error-reactivation"></small></p>
<button type="submit" name="submit_reactivation" class="button button-primary" id="reactivation-form-submit" disabled="disabled">{$aLang.reactivation_submit}</button>
</form>
{include file='footer.tpl'}

View file

@ -0,0 +1,7 @@
You have requested re-activation on the site <a href="{cfg name='path.root.web'}">{cfg name='view.name'}</a><br>
Link to the account activation:
<a href="{router page='registration'}activate/{$oUser->getActivateKey()}/">{router page='registration'}activate/{$oUser->getActivateKey()}/</a>
<br><br>
Best regards, site administration <a href="{cfg name='path.root.web'}">{cfg name='view.name'}</a>

View file

@ -0,0 +1,7 @@
Вы запросили повторную активацию на сайте <a href="{cfg name='path.root.web'}">{cfg name='view.name'}</a><br>
Ссылка на активацию аккаунта:
<a href="{router page='registration'}activate/{$oUser->getActivateKey()}/">{router page='registration'}activate/{$oUser->getActivateKey()}/</a>
<br><br>
С уважением, администрация сайта <a href="{cfg name='path.root.web'}">{cfg name='view.name'}</a>