-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
27,874 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
defined('DS') or exit('No direct access.'); | ||
|
||
class Admin_Dashboard_Controller extends Controller | ||
{ | ||
public $restful = true; | ||
|
||
public function __construct() | ||
{ | ||
$this->middleware('before', 'csrf|throttle:60,1|admin'); | ||
} | ||
|
||
public function get_index() | ||
{ | ||
return View::make('admin.dashboard'); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
No direct access. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
defined('DS') or exit('No direct access.'); | ||
|
||
class Auth_Login_Controller extends Controller | ||
{ | ||
public $restful = true; | ||
|
||
public function __construct() | ||
{ | ||
$this->middleware('before', 'csrf|throttle:60,1'); | ||
} | ||
|
||
public function get_login() | ||
{ | ||
return View::make('auth.login'); | ||
} | ||
|
||
public function post_login() | ||
{ | ||
$validation = Validator::make(Input::all(), [ | ||
'email' => 'required|email', | ||
'password' => 'required', | ||
]); | ||
|
||
if ($validation->fails()) { | ||
return Redirect::back() | ||
->with_input() | ||
->with_errors($validation); | ||
} | ||
|
||
$credentials = Input::only('email', 'password'); | ||
$remember = Input::has('remember'); | ||
|
||
if (!Auth::attempt($credentials, $remember)) { | ||
return Redirect::back() | ||
->with_input() | ||
->with('error', 'Invalid credentials.'); | ||
} | ||
|
||
return Redirect::to(Auth::user()->role === 'admin' ? 'admin' : 'member'); | ||
} | ||
|
||
public function post_logout() | ||
{ | ||
Auth::logout(); | ||
return Redirect::to('/'); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
defined('DS') or exit('No direct access.'); | ||
|
||
class Auth_Password_Controller extends Controller | ||
{ | ||
public $restful = true; | ||
|
||
public function __construct() | ||
{ | ||
$this->middleware('before', 'csrf|throttle:60,1'); | ||
} | ||
|
||
public function get_resend() | ||
{ | ||
return View::make('auth.passwords.email'); | ||
} | ||
|
||
public function post_resend() | ||
{ | ||
$validation = Validator::make(Input::all(), [ | ||
'email' => 'required|email|exists:users|max:191', | ||
]); | ||
|
||
if ($validation->fails()) { | ||
return Redirect::back() | ||
->with_input() | ||
->with_errors($validation); | ||
} | ||
|
||
$token = Str::random(); | ||
|
||
DB::table('password_resets')->insert([ | ||
'email' => Input::get('email'), | ||
'token' => $token, | ||
'created_at' => now(), | ||
]); | ||
|
||
$html = View::make('auth.email.reset', compact('token'))->render(); | ||
Email::from(config('email.from.email')) | ||
->to(Input::get('email')) | ||
->subject('Reset Password') | ||
->html_body($html) | ||
->priority(Email::HIGH) | ||
->send(); | ||
|
||
return Redirect::back() | ||
->with('status', 'A password reset link has been sent to your email address.'); | ||
} | ||
|
||
public function get_reset() | ||
{ | ||
$token = URI::segment(3); | ||
|
||
if (!$token) { | ||
return Response::error(404); | ||
} | ||
|
||
$reset = DB::table('password_resets') | ||
->where('token', $token) | ||
->first(); | ||
|
||
if (!$reset) { | ||
return Response::error(404); | ||
} | ||
|
||
return View::make('auth.passwords.reset') | ||
->with('token', $reset->token); | ||
} | ||
|
||
public function post_reset() | ||
{ | ||
$validation = Validator::make(Input::all(), [ | ||
'token' => 'required', | ||
'email' => 'required|email|max:191', | ||
'password' => 'required|confirmed|min:8|max:191', | ||
]); | ||
|
||
if ($validation->fails()) { | ||
return Redirect::back() | ||
->with_input() | ||
->with_errors($validation) | ||
->with('token', Input::get('token')); | ||
} | ||
|
||
$reset = DB::table('password_resets') | ||
->where('token', Input::get('token')) | ||
->first(); | ||
|
||
abort_if(!$reset, 404); | ||
|
||
$user = DB::table('users')->where('email', Input::get('email'))->first(); | ||
|
||
abort_if(!$user, 404); | ||
|
||
DB::table('users')->where('id', $user->id)->update([ | ||
'password' => Hash::make(Input::get('password')), | ||
'updated_at' => now(), | ||
]); | ||
|
||
DB::table('password_resets')->delete($reset->id); | ||
|
||
Auth::login($user->id); | ||
|
||
return Redirect::to('/dashboard') | ||
->with('status', sprintf( | ||
'Your password has been successfuly reset to: %s', | ||
Input::get('password') | ||
)); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
defined('DS') or exit('No direct access.'); | ||
|
||
class Auth_Register_Controller extends Controller | ||
{ | ||
public $restful = true; | ||
|
||
public function __construct() | ||
{ | ||
$this->middleware('before', 'csrf|throttle:60,1'); | ||
} | ||
|
||
public function get_register() | ||
{ | ||
return View::make('auth.register'); | ||
} | ||
|
||
public function post_register() | ||
{ | ||
$validation = Validator::make(Input::all(), [ | ||
'name' => 'required|min:3|max:191', | ||
'email' => 'required|email|max:191|unique:users', | ||
'phone' => 'required|min:10|max:15|unique:users', | ||
'password' => 'required|confirmed|min:8|max:191', | ||
]); | ||
|
||
if ($validation->fails()) { | ||
return Redirect::back() | ||
->with_input() | ||
->with_errors($validation); | ||
} | ||
|
||
$user_id = DB::table('users')->insert_get_id([ | ||
'name' => Input::get('name'), | ||
'email' => Input::get('email'), | ||
'phone' => Input::get('phone'), | ||
'password' => Hash::make(Input::get('password')), | ||
'created_at' => now(), | ||
]); | ||
|
||
Auth::login($user_id); | ||
return Redirect::to('/dashboard'); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
defined('DS') or exit('No direct access.'); | ||
|
||
class Member_Dashboard_Controller extends Controller | ||
{ | ||
public $restful = true; | ||
|
||
public function __construct() | ||
{ | ||
$this->middleware('before', 'csrf|throttle:60,1|auth'); | ||
} | ||
|
||
public function get_index() | ||
{ | ||
return View::make('member.dashboard'); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
No direct access. |
Oops, something went wrong.