Skip to content

Instantly share code, notes, and snippets.

@mateusgf
Created July 19, 2013 14:31
Show Gist options
  • Save mateusgf/6039501 to your computer and use it in GitHub Desktop.
Save mateusgf/6039501 to your computer and use it in GitHub Desktop.
<?php
class Users_Controller extends Base_Controller {
public $restful = true;
public function get_new() {
return View::make('users.new')
->with('title', 'Make It Snappy Q&A - Register');
}
public function post_create() {
$validation = User::validate(Input::all());
if ($validation->passes()) {
User::create(array(
'username'=>Input::get('username'),
'password'=>Hash::make(Input::get('password'))
));
$user = User::where_username(Input::get('username'))->first();
Auth::login($user);
return Redirect::to_route('home')
->with('message', 'Thanks for registering. Your are now logged in!');
} else {
return Redirect::to_route('register')->with_errors($validation)->with_input();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment