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
Clark Chen
committed
Jun 11, 2014
1 parent
8bead74
commit 7c65beb
Showing
36 changed files
with
9,226 additions
and
8 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,120 @@ | ||
<?php | ||
|
||
class AccountController extends BaseController { | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Default Home Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| You may wish to use controllers instead of, or in addition to, Closure | ||
| based routes. That's great! Here is an example controller method to | ||
| get you started. To route to this controller, just add the route: | ||
| | ||
| Route::get('/', 'HomeController@showWelcome'); | ||
| | ||
*/ | ||
protected $layout = 'layouts.master'; | ||
public function getActivate($code) | ||
{ | ||
$user = User::where('activation_code', '=', $code)->where('active', '=', '0'); | ||
|
||
if($user->count()){ | ||
$user = $user->first(); | ||
|
||
$user->active = '1'; | ||
$user->activation_code = ''; | ||
|
||
if($user->save()) { | ||
return Redirect::route('login')->with('success_message', 'Activated! You can sign in now :)'); | ||
} | ||
} | ||
return Redirect::route('login')->with('error_message', 'Something went wrong with your activation :('); | ||
} | ||
public function postLogin() | ||
{ | ||
$validator = Validator::make(Input::all(), | ||
array( | ||
'email' => 'required|email', | ||
'password' => 'required' | ||
) | ||
); | ||
if($validator->fails()) { | ||
return Redirect::route('login') | ||
->withErrors($validator) | ||
->withInput(); | ||
} | ||
else { | ||
$auth = Auth::attempt(array( | ||
'email' => Input::get('email'), | ||
'password' => Input::get('password'), | ||
'active' => 1) | ||
); | ||
|
||
if($auth) { | ||
return Redirect::intended('/'); | ||
} | ||
else { | ||
return Redirect::route('login')->withInput()->with('error_message', 'Incorrect credentials or account not activated.'); | ||
} | ||
} | ||
|
||
return Redirect::route('login') | ||
->with('error_message', 'There was a problem signing in.'); | ||
} | ||
|
||
public function getLogin() | ||
{ | ||
$this->layout->content = View::make('login'); | ||
} | ||
|
||
public function getRegistration() | ||
{ | ||
$this->layout->content = View::make('registration'); | ||
} | ||
public function postRegistration() | ||
{ | ||
$validator = Validator::make(Input::all(), | ||
array( | ||
'email' => 'required|max:254|email|unique:users', | ||
'username' => 'required|max:30|min:3|unique:users', | ||
'password' => 'required|min:8', | ||
'confirmpassword' => 'required|same:password' | ||
) | ||
); | ||
if($validator->fails()) { | ||
return Redirect::route('register') | ||
->withErrors($validator) | ||
->withInput(); | ||
} | ||
else { | ||
$email = Input::get('email'); | ||
$username = Input::get('username'); | ||
$password = Input::get('password'); | ||
|
||
//Activation code generation | ||
$activcode = str_random(60); | ||
|
||
$user = User::create(array( | ||
'email' => $email, | ||
'username' => $username, | ||
'password' => Hash::make($password), | ||
'activation_code' => $activcode)); | ||
|
||
if($user) { | ||
|
||
/*Mail::send('emails.auth.activate', array('link' => URL::route('activate', $activcode), 'username' => $username), function($message) use $user { | ||
$message->to($user->email, $user->username)->subject('Activate your MabiMart Account'); | ||
}); | ||
return Redirect::route('login')->with('success_message', 'Your account has been created. Please visit your e-mail address and activate it.');*/ | ||
|
||
} | ||
else { | ||
Redirect::route('register') | ||
->withInput(); | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
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,47 @@ | ||
<?php | ||
|
||
class LoginController extends BaseController { | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Default Home Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| You may wish to use controllers instead of, or in addition to, Closure | ||
| based routes. That's great! Here is an example controller method to | ||
| get you started. To route to this controller, just add the route: | ||
| | ||
| Route::get('/', 'HomeController@showWelcome'); | ||
| | ||
*/ | ||
protected $layout = 'layouts.master'; | ||
|
||
public function get() | ||
{ | ||
if (Auth::check()) { | ||
return Redirect::intended('dashboard'); | ||
} | ||
else { | ||
$this->layout->content = View::make('login'); | ||
} | ||
} | ||
public function login() | ||
{ | ||
if(Input::has('email') && Input::has('password')) { | ||
$email = Input::get('email'); | ||
$password = Input::get('password'); | ||
$rememberme = Input::get('remember', false); | ||
if (Auth::attempt(array('email' => $email, 'password' => $password), $rememberme)) | ||
{ | ||
return Redirect::intended('dashboard'); | ||
} | ||
else { | ||
$this->layout->content = View::make('login')->with('error', 'Incorrect e-mail address or password'); | ||
} | ||
|
||
} | ||
else { | ||
$this->layout->content = View::make('login')->with('error', 'You did not specify an e-mail or password'); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/database/migrations/2014_06_10_224409_create_users_table.php
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,42 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateUsersTable extends Migration { | ||
|
||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('users', function(Blueprint $table) | ||
{ | ||
$table->increments('id'); | ||
|
||
$table->string('username',32); | ||
$table->string('email', 320); | ||
$table->string('password', 64); | ||
|
||
$table->string('remember_token', 100)->nullable(); | ||
|
||
$table->string('activation_code', 60); | ||
$table->boolean('active')->default(false); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::drop('users'); | ||
} | ||
|
||
} |
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,15 @@ | ||
Hiya {{ $username }}! | ||
|
||
Thanks for registering for an account at MabiMart! All that's left is for you to activate your account. | ||
<br> | ||
Just visit the URL below to activate your account.<br> | ||
--- | ||
{{ $link }}<br> | ||
--- | ||
<br> | ||
<br> | ||
Remember, till then you won't be able to login to your account! | ||
|
||
<br><br> | ||
Thanks,<br> | ||
- Rhaenyx (MabiMart creator) |
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,53 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<title>MabiMart | @yield('page-title')</title> | ||
<link href="css/bootstrap.min.css" rel="stylesheet"> | ||
|
||
<link href="css/style.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div class="container" id="logoarea"> | ||
<div class="col-xs-2 col-md-2"> | ||
<img src="images/logo.png"> | ||
</div> | ||
<!--<div class="col-xs-3 pull-right col-md-2 text-right" id="userpanel"> | ||
Welcome, <b>Guest</b>. </br> Please <a href="/login">Login</a> or <a href="/register">Register</a>. | ||
</div>--> | ||
</div> | ||
<div class="navbar-inverse navbar-default" role="navigation" id="navbar"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
<span class="sr-only">Toggle navigation</span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
</div> | ||
<div class="navbar-collapse collapse"> | ||
<ul class="nav navbar-nav"> | ||
<li><a href="#">Home</a></li> | ||
@if(Auth::check()) | ||
<li>You successfully logged in.</li> | ||
@else | ||
<li><a href="{{ URL::route('login') }}">Login</a> | ||
@endif | ||
|
||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="container" id="content"> | ||
@yield('content') | ||
<div id="footer" class="col-md-12 col-xs-12"> | ||
Copyright © 2014 MabiMart. Built lovingly with <a href="http://getbootstrap.com/">Bootstrap</a>. | ||
</div> | ||
</div> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | ||
<script src="js/bootstrap.min.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.