Skip to content

Commit

Permalink
Merge pull request #64 from AdwinTrave/CI3
Browse files Browse the repository at this point in the history
Fixing bugs in Sign up
  • Loading branch information
donjakobo committed Sep 19, 2013
2 parents b68a313 + a56c7c7 commit 91ed16c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
15 changes: 10 additions & 5 deletions application/controllers/account/Sign_up.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function index()
if (($this->form_validation->run() === TRUE) && ($this->config->item("sign_up_enabled")))
{
// Either already pass recaptcha or just passed recaptcha
if ( ! ($this->session->userdata('sign_up_recaptcha_pass') == TRUE || $recaptcha_result === TRUE) && $this->config->item("sign_up_recaptcha_enabled") === TRUE)
if ( ($this->session->userdata('sign_up_recaptcha_pass') == FALSE || $recaptcha_result === FALSE) && $this->config->item("sign_up_recaptcha_enabled") === TRUE)
{
$data['sign_up_recaptcha_error'] = $this->input->post('recaptcha_response_field') ? lang('sign_up_recaptcha_incorrect') : lang('sign_up_recaptcha_required');
}
Expand Down Expand Up @@ -88,13 +88,16 @@ function index()
*/
function username_check($username)
{
if($this->account_model->get_by_username($username))
//once we update to PHP 5.5, we will be able to put this into the if statement
$result = $this->account_model->get_by_username($username);
if( empty($result) )
{
return TRUE;
}
else
{
$this->form_validation->set_message('sign_up_username', 'lang:sign_up_username_taken');
$error = lang('sign_up_username_taken');
$this->form_validation->set_message('username_check', $error);
return FALSE;
}
}
Expand All @@ -108,13 +111,15 @@ function username_check($username)
*/
function email_check($email)
{
if($this->account_model->get_by_email($email))
$result = $this->account_model->get_by_email($email);
if( empty($result) )
{
return TRUE;
}
else
{
$this->form_validation->set_message('sign_up_email', 'lang:');
$error = lang('sign_up_email_exist');
$this->form_validation->set_message('email_check', $error);
return FALSE;
}
}
Expand Down
11 changes: 5 additions & 6 deletions application/views/sign_up.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<h3><?php echo lang('sign_up_heading'); ?></h3>

<div class="well">

<div class="control-group <?php echo (form_error('sign_up_username') || isset($sign_up_username_error)) ? 'error' : ''; ?>">
<label class="control-label" for="sign_up_username"><?php echo lang('sign_up_username'); ?></label>

Expand Down Expand Up @@ -75,14 +74,14 @@
</div>
</div>

<div class="control-group <?php echo (form_error('sign_up_password')) ? 'error' : ''; ?>">
<label class="control-label" for="sign_up_confirm_password"><?php echo lang('sign_up_confirm_password'); ?></label>
<div class="control-group <?php echo (form_error('sign_up_password_confirm')) ? 'error' : ''; ?>">
<label class="control-label" for="sign_up_password_confirm"><?php echo lang('sign_up_confirm_password'); ?></label>

<div class="controls">
<?php echo form_password(array('name' => 'sign_up_confirm_password', 'id' => 'sign_up_confirm_password', 'value' => set_value('sign_up_confirm_password'))); ?>
<?php if (form_error('sign_up_confirm_password')) : ?>
<?php echo form_password(array('name' => 'sign_up_password_confirm', 'id' => 'sign_up_password_confirm', 'value' => set_value('sign_up_password_confirm'))); ?>
<?php if (form_error('sign_up_password_confirm')) : ?>
<span class="help-inline">
<?php echo form_error('sign_up_confirm_password'); ?>
<?php echo form_error('sign_up_password_confirm'); ?>
</span>
<?php endif; ?>
</div>
Expand Down

0 comments on commit 91ed16c

Please sign in to comment.