Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Commit

Permalink
#702: Finish basic register page functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
franzliedke committed Jul 11, 2012
1 parent f67d36e commit 77e8bd3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 4 deletions.
50 changes: 50 additions & 0 deletions controllers/auth.php
Expand Up @@ -42,6 +42,12 @@ public function get_login()

public function get_register()
{
// TODO: Moving this to a filter might make sense!
if ($this->user()->is_member())
{
return Redirect::to_action('fluxbb::home@index');
}

// TODO: Remember old values, too
$timezone = 1; // $pun_config['o_default_timezone']
$dst = 1; // $pun_config['o_default_dst']
Expand All @@ -55,4 +61,48 @@ public function get_register()
->with('email_setting', $email_setting);
}

public function post_register()
{
if ($this->user()->is_member())
{
return Redirect::to_action('fluxbb::home@index');
}

// TODO: Add agreement to rules here!

$rules = array(
// TODO: Reserved chars, BBCode, IP + case-insensitivity for "Guest", censored words, name doesn't exist
'req_user' => 'required|min:2|max:25|not_in:Guest,'.__('fluxbb::common.guest'),
// TODO: No password if o_regs_verify == 1
'req_password' => 'required|min:4|confirmed',
// TODO: only check for confirmation if o_regs_verify == 1, also add check for banned email
'req_email' => 'required|email|confirmed|unique:users,email',
);
// TODO: More validation

$validation = Validator::make(Input::all(), $rules);
if ($validation->fails())
{
return Redirect::to_action('fluxbb::auth@register')->with_errors($validation);
}

$user_data = array(
'username' => Input::get('req_user'),
'group_id' => 4, // TODO: ($pun_config['o_regs_verify'] == '0') ? $pun_config['o_default_user_group'] : PUN_UNVERIFIED
'password' => Input::get('req_password'),
'email' => Input::get('req_email'),
'email_setting' => Input::get('email_setting'),
'timezone' => Input::get('timezone'), // TODO: default to $pun_config['o_default_dst']
'dst' => Input::get('dst'),
'language' => Input::get('language'),
'style' => 'Air', // TODO: Default style!!!
'registered' => time(), // TODO: Request::time()? https://github.com/laravel/laravel/pull/933
'registration_ip' => Request::ip(),
'last_visit' => time(),
);
$user = User::create($user_data);

return Redirect::to_action('fluxbb::user@profile', array($user->id))->with('message', __('fluxbb::register.reg_complete'));
}

}
1 change: 1 addition & 0 deletions language/en/register.php
Expand Up @@ -11,5 +11,6 @@
'info_pass' => 'Passwords must be at least 4 characters long. Passwords are case sensitive.',
'info_email' => 'You must enter a valid email address as your randomly generated password will be sent to that address.',
'confirm_email' => 'Confirm email address',
'reg_complete' => 'Registration complete. Logged in.',

);
7 changes: 7 additions & 0 deletions models/user.php
Expand Up @@ -26,6 +26,7 @@
namespace fluxbb;

use Auth;
use Hash;

class User extends \FluxBB_BaseModel
{
Expand Down Expand Up @@ -202,4 +203,10 @@ public function disp_posts()
return $this->disp_posts ?: 25; // TODO: $pun_config['o_disp_posts_default'];
}

public function set_password($password)
{
$this->set_attribute('password', Hash::make($password));
// TODO: Maybe reset some attributes like confirmation code here?
}

}
9 changes: 5 additions & 4 deletions views/auth/register.blade.php
@@ -1,6 +1,7 @@
@layout('fluxbb::layout.main')

@section('main')
<?php print_r($errors); ?>
<div id="regform" class="blockform">
<h2><span>{{ __('fluxbb::register.register') }}</span></h2>
<div class="box">
Expand All @@ -26,8 +27,8 @@
<fieldset>
<legend>{{ __('fluxbb::register.legend_pass') }}</legend>
<div class="infldset">
<label class="conl required"><strong>{{ __('fluxbb::common.password') }} <span>{{ __('fluxbb::common.required') }}</span></strong><br /><input type="password" name="req_password1" size="16" /><br /></label>
<label class="conl required"><strong>{{ __('fluxbb::prof_reg.confirm_pass') }} <span>{{ __('fluxbb::common.required') }}</span></strong><br /><input type="password" name="req_password2" size="16" /><br /></label>
<label class="conl required"><strong>{{ __('fluxbb::common.password') }} <span>{{ __('fluxbb::common.required') }}</span></strong><br /><input type="password" name="req_password" size="16" /><br /></label>
<label class="conl required"><strong>{{ __('fluxbb::prof_reg.confirm_pass') }} <span>{{ __('fluxbb::common.required') }}</span></strong><br /><input type="password" name="req_password_confirmation" size="16" /><br /></label>
<p class="clearb">{{ __('fluxbb::register.info_pass') }}</p>
</div>
</fieldset>
Expand All @@ -47,11 +48,11 @@
<p>{{ __('fluxbb::register.info_email') }}</p>
@endif
<label class="required"><strong>{{ __('fluxbb::common.email') }} <span>{{ __('fluxbb::common.required') }}</span></strong><br />
<input type="text" name="req_email1" size="50" maxlength="80" /><br /></label>
<input type="text" name="req_email" size="50" maxlength="80" /><br /></label>
{{-- TODO: if ($pun_config['o_regs_verify'] == '1') --}}
@if (true)
<label class="required"><strong>{{ __('fluxbb::register.confirm_email') }} <span>{{ __('fluxbb::common.required') }}</span></strong><br />
<input type="text" name="req_email2" size="50" maxlength="80" /><br /></label>
<input type="text" name="req_email_confirmation" size="50" maxlength="80" /><br /></label>
@endif
</div>
</fieldset>
Expand Down

0 comments on commit 77e8bd3

Please sign in to comment.