Created
July 19, 2013 14:31
-
-
Save mateusgf/6039501 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?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