1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-01 10:50:37 +02:00

Users Plugin: Admin - New User Registration - Fixed

This commit is contained in:
Awilum
2012-10-02 23:04:36 +03:00
parent 10d82e98cf
commit 42998d476f
2 changed files with 16 additions and 5 deletions

View File

@@ -67,17 +67,22 @@
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
// Errors
$errors = array();
if (Request::post('register')) {
if (Security::check(Request::post('csrf'))) {
$user_login = trim(Request::post('login'));
$user_login = trim(Request::post('login'));
$user_password = trim(Request::post('password'));
$user_email = trim(Request::post('email'));
if ($user_login == '') $errors['users_empty_login'] = __('Required field', 'users');
if ($user_password == '') $errors['users_empty_password'] = __('Required field', 'users');
$user = $users->select("[login='".$user_login."']");
if ($user != null) $errors['users_this_user_alredy_exists'] = __('This user alredy exist', 'users');
if ($user_email == '') $errors['users_empty_email'] = __('Required field', 'users');
if ($users->select("[login='".$user_login."']")) $errors['users_this_user_alredy_exists'] = __('This user alredy exist', 'users');
if ($users->select("[email='".$user_email."']")) $errors['users_this_email_alredy_exists'] = __('This email alredy exist', 'users');
if (count($errors) == 0) {
$users->insert(array('login' => Security::safeName($user_login),

View File

@@ -10,7 +10,7 @@
Form::input('login', null, array('class' => (isset($errors['users_this_user_alredy_exists']) || isset($errors['users_empty_login'])) ? 'span3 error-field' : 'span3'))
);
if (isset($errors['users_this_user_alredy_exists'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_this_user_alredy_exists'].'</span>';
if (isset($errors['users_this_user_alredy_exists'])) echo Html::nbsp(3).'<span style="color:red">'.$errors['users_this_user_alredy_exists'].'</span>';
if (isset($errors['users_empty_login'])) echo Html::nbsp(3).'<span style="color:red">'.$errors['users_empty_login'].'</span>';
echo (
@@ -22,7 +22,13 @@
echo (
Form::label('email', __('Email', 'users')).
Form::input('email', null, array('class' => 'span3')). Html::br().
Form::input('email', null, array('class' => (isset($errors['users_this_email_alredy_exists']) || isset($errors['users_empty_email'])) ? 'span3 error-field' : 'span3'))
);
if (isset($errors['users_this_email_alredy_exists'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_this_email_alredy_exists'].'</span>';
if (isset($errors['users_empty_email'])) echo Html::nbsp(3).'<span style="color:red">'.$errors['users_empty_email'].'</span>';
echo(
Form::label('role', __('Role', 'users')).
Form::select('role', array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users')), null, array('class' => 'span3')). Html::br(2).
Form::submit('register', __('Register', 'users'), array('class' => 'btn default')).