diff --git a/.gitignore b/.gitignore index aa767d2..7a52d03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/app/config/database.php /bootstrap/compiled.php /vendor composer.phar diff --git a/app/database/migrations/2014_04_01_221339_create_users_table.php b/app/database/migrations/2014_04_01_221339_create_users_table.php new file mode 100644 index 0000000..067afbd --- /dev/null +++ b/app/database/migrations/2014_04_01_221339_create_users_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->string('email'); + $table->string('password'); + $table->string('name'); + $table->integer('status'); + $table->timestamps(); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('users'); + } + +} diff --git a/app/database/seeds/DatabaseSeeder.php b/app/database/seeds/DatabaseSeeder.php index 6a8c204..eb6fd45 100644 --- a/app/database/seeds/DatabaseSeeder.php +++ b/app/database/seeds/DatabaseSeeder.php @@ -11,7 +11,7 @@ public function run() { Eloquent::unguard(); - // $this->call('UserTableSeeder'); + $this->call('UsersTableSeeder'); } } \ No newline at end of file diff --git a/app/database/seeds/UsersTableSeeder.php b/app/database/seeds/UsersTableSeeder.php new file mode 100644 index 0000000..ab67e2e --- /dev/null +++ b/app/database/seeds/UsersTableSeeder.php @@ -0,0 +1,19 @@ +delete(); + + User::create(array( + "email" => "admin@lore.io", + "password" => Hash::make('admin'), + "name" => "Administrator", + "status" => 1, + "created_at" => new DateTime, + "updated_at" => new DateTime, + )); + } + +} \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index e2a75e2..b2e22f5 100644 --- a/app/routes.php +++ b/app/routes.php @@ -11,7 +11,28 @@ | */ -Route::get('/', function() +Route::get('/', array("before" => "auth", function() { return View::make('hello'); +})); + +Route::get('/login', array('as' => 'login', function() { + return View::make('login'); +})); + +Route::get('/logout', array('as' => 'logout', "before" => "auth", function() { + Auth::logout(); + return Redirect::to('login'); +})); + +Route::post('/login', function() { + $cred = Input::only('email', 'password'); + + $cred["status"] = 1; // Filter the disabled users + + if (Auth::attempt($cred)) { + return Redirect::intended('/'); + } + + return View::make('login')->with('fail', true); }); \ No newline at end of file diff --git a/app/views/hello.php b/app/views/hello.blade.php similarity index 99% rename from app/views/hello.php rename to app/views/hello.blade.php index d8b85b8..fadbcf8 100644 --- a/app/views/hello.php +++ b/app/views/hello.blade.php @@ -37,6 +37,8 @@