-
-
Save Fi1osof/6c1b7caca5d4cb3de1f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{* | |
Регистрация нового пользователя | |
*} | |
{if $modx->user->hasSessionContext($modx->context->key)} | |
{include file="layout/text/success.tpl" message="Вы уже авторизованы"} | |
{else} | |
{$request = []} | |
{if $smarty.session.social_profile && $smarty.session.social_profile.provider && $smarty.session.social_profile.profile} | |
{$social_profile = $modx->newObject('modHybridAuthUserProfile', $smarty.session.social_profile.profile)} | |
{$request.email = $social_profile->email} | |
{$request.fullname = trim("{$social_profile->firstName} {$social_profile->lastName}")} | |
{$request.username = $social_profile->displayName} | |
{/if} | |
{if $smarty.post.reg_submit} | |
{$request = array_merge($request, [ | |
"username" => $smarty.post.username, | |
"fullname" => $smarty.post.fullname, | |
"email" => $smarty.post.email, | |
"captcha" => $smarty.post.captcha | |
])} | |
{processor action="web/society/users/create" ns="modxsite" params=$request assign=reg_result} | |
{/if} | |
{if !$reg_result.success} | |
<div class="form-group "> | |
{if $social_profile} | |
{* | |
Если пользователь авторизован в соцсети, сообщаем ему об этом, чтобы меньше путаницы было | |
*} | |
<p class="text-primary">Вы успешно авторизованы в социальной сети, осталось для регистрации заполнить пару полей.</p> | |
{else} | |
{* | |
Иначе выводим иконки для регистрации через соцсети | |
*} | |
<div> | |
<span class="text-primary">Регистрация через социальную сеть: </span> | |
<a href="[[++assets_url]]components/modhybridauth/connectors/profile/auth.php?provider=Twitter&redirect_id=[[*id]]" alt="Twitter" title="Войти через Twitter" class="social Twitter"></a> | |
<a href="[[++assets_url]]components/modhybridauth/connectors/profile/auth.php?provider=Facebook&redirect_id=[[*id]]" alt="Facebook" title="Войти через Facebook" class="social Facebook"></a> | |
<a href="[[++assets_url]]components/modhybridauth/connectors/profile/auth.php?provider=Google&redirect_id=[[*id]]" alt="Google" title="Войти через Google" class="social Google"></a> | |
<a href="[[++assets_url]]components/modhybridauth/connectors/profile/auth.php?provider=Yandex&redirect_id=[[*id]]" alt="Yandex" title="Войти через Yandex" class="social Yandex"></a> | |
</div> | |
{/if} | |
</div> | |
{/if} | |
{* | |
Результат выполнения процессора | |
*} | |
{if $reg_result} | |
{if $reg_result.success} | |
{include file="layout/text/success.tpl" message=$reg_result.message|default:"Вы успешно зарегистрированы"} | |
{else} | |
{include file="layout/text/error.tpl" message=$reg_result.message|default:"Ошибка выполнения запроса"} | |
{/if} | |
{/if} | |
{* | |
Если процессор не был успешно выполнен, выводим форму для регистрации | |
*} | |
{if !$reg_result.success} | |
<form id="reg_form" method="post" action=""> | |
<div class="row"> | |
<div class="col-xs-8"> | |
<div class="form-group {if $reg_result.field_errors.username}has-error{/if}"> | |
<input type="text" class="form-control input-hg" placeholder="Логин" name="username" value="{$request.username}" autocomplete="off"> | |
{if $reg_result.field_errors.username} | |
<p class="text-danger">{$reg_result.field_errors.username}</p> | |
{/if} | |
</div> | |
<div class="form-group {if $reg_result.field_errors.fullname}has-error{/if}"> | |
<input type="text" class="form-control input-hg" placeholder="ФИО" name="fullname" value="{$request.fullname}" autocomplete="off"> | |
{if $reg_result.field_errors.fullname} | |
<p class="text-danger">{$reg_result.field_errors.fullname}</p> | |
{/if} | |
</div> | |
<div class="form-group {if $reg_result.field_errors.email}has-error{/if}"> | |
<input type="email" class="form-control input-hg" placeholder="Емейл" name="email" value="{$request.email}" autocomplete="off"> | |
{if $reg_result.field_errors.email} | |
<p class="text-danger">{$reg_result.field_errors.email}</p> | |
{/if} | |
</div> | |
{if !$social_profile} | |
<div class="row"> | |
<div class="col-xs-8"> | |
<div class="form-group"> | |
<input type="text" class="form-control input-hg" placeholder="Код с картинки" name="captcha" value="" autocomplete="off"> | |
</div> | |
</div> | |
<div class="col-xs-4"> | |
{chunk name=modcaptcha} | |
</div> | |
</div> | |
{/if} | |
<div class="row"> | |
<div class="col-xs-12"> | |
<div class="form-group"> | |
<input type="submit" class="btn btn-success btn-wide" name="reg_submit" value="Зарегистрироваться" /> | |
</div> | |
</div> | |
</div> | |
<hr /> | |
<p>Если вы были зарегистрированы ранее, можете попробовать <a href="[[~1008]]">восстановить пароль</a></p> | |
</div> | |
</div> | |
</form> | |
{/if} | |
{/if} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment