diff --git a/app/config/mail.php b/app/config/mail.php index 41b4c4b..4f99bd1 100755 --- a/app/config/mail.php +++ b/app/config/mail.php @@ -28,7 +28,7 @@ return array( | */ - 'host' => 'smtp.mailgun.org', + 'host' => 'smtp.gmail.com', /* |-------------------------------------------------------------------------- @@ -54,7 +54,7 @@ return array( | */ - 'from' => array('address' => null, 'name' => null), + 'from' => array('address' => 'elisha.java@gmail.com', 'name' => 'Mentconnect Team'), /* |-------------------------------------------------------------------------- @@ -80,7 +80,7 @@ return array( | */ - 'username' => null, + 'username' => 'elisha.java', /* |-------------------------------------------------------------------------- @@ -93,7 +93,7 @@ return array( | */ - 'password' => null, + 'password' => '$_KIPsigei2003#', /* |-------------------------------------------------------------------------- diff --git a/app/controllers/LoginController.php b/app/controllers/LoginController.php deleted file mode 100644 index 5528452..0000000 --- a/app/controllers/LoginController.php +++ /dev/null @@ -1,65 +0,0 @@ - 'required|email', // make sure the email is an actual email - 'password' => 'required|alphaNum|min:3' // password can only be alphanumeric and has to be greater than 3 characters - ); - - // run the validation rules on the inputs from the form - $validator = Validator::make(Input::all(), $rules); - - // if the validator fails, redirect back to the form - if ($validator->fails()) { - return Redirect::to('login') - ->withErrors($validator) // send back all errors to the login form - ->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form - } else { - - // create our user data for the authentication - $userdata = array( - 'email' => Input::get('email'), - 'password' => Input::get('password') - ); - - // attempt to do the login - if (Auth::attempt($userdata)) { - - // validation successful! - // redirect them to the secure section or whatever - // return Redirect::to('secure'); - // for now we'll just echo success (even though echoing in a controller is bad) - return \Redirect::to('/'); - - } else { - - // validation not successful, send back to form - return \Redirect::to('login'); - - } - - } - } - - public function doLogout() - { - Auth::logout(); // log the user out of our application - return \Redirect::to('/'); // redirect the user to the login screen - } - - public function register() - { - return View::make('mentors.register'); - } - -} \ No newline at end of file diff --git a/app/controllers/MentorController.php b/app/controllers/MentorController.php deleted file mode 100644 index ab78d17..0000000 --- a/app/controllers/MentorController.php +++ /dev/null @@ -1,87 +0,0 @@ -get(); - return View::make('mentors.profile')->with('mentor', $mentor); - } - - - /** - * Show the form for editing the specified resource. - * - * @param int $id - * @return Response - */ - public function edit($id) - { - // - } - - - /** - * Update the specified resource in storage. - * - * @param int $id - * @return Response - */ - public function update($id) - { - // - } - - - /** - * Remove the specified resource from storage. - * - * @param int $id - * @return Response - */ - public function destroy($id) - { - // - } - - -} diff --git a/app/controllers/RemindersController.php b/app/controllers/RemindersController.php new file mode 100644 index 0000000..2b47675 --- /dev/null +++ b/app/controllers/RemindersController.php @@ -0,0 +1,111 @@ + 'required|email', + ); + + $validator = Validator::make(Input::all(), $rules); + + if ($validator->fails()) + { + return Redirect::to('password/remind') + ->withErrors($validator) + ->withInput(Input::except('password')); + }else + { + switch ($response = Password::remind(Input::only('email'))) + { + case Password::INVALID_USER: + \Session::flash('message', 'The email you entered does not exist. Try a different email.'); + return Redirect::back()->with('error', Lang::get($response)); + + case Password::REMINDER_SENT: + \Session::flash('message', 'Please check your email for information on how to reset your password.'); + return Redirect::back()->with('status', Lang::get($response)); + } + } + + } + + /** + * Display the password reset view for the given token. + * + * @param string $token + * @return Response + */ + public function getReset($token = null) + { + if (is_null($token)) App::abort(404); + + return View::make('password.reset')->with('token', $token); + } + + /** + * Handle a POST request to reset a user's password. + * + * @return Response + */ + public function postReset() + { + //validate input here + $rules = array( + 'email' => 'required|email', + 'password' => 'required|password', + 'password_confirmation' => 'required', + 'token' => 'required', + ); + + $validator = Validator::make(Input::all(), $rules); + + if ($validator->fails()) + { + return Redirect::back() + ->withErrors($validator) + ->withInput(Input::except('password', 'password_confirmation')); + } + + $credentials = Input::only( + 'email', 'password', 'password_confirmation', 'token' + ); + + $response = Password::reset($credentials, function($user, $password) + { + $user->password = Hash::make($password); + + $user->save(); + }); + + switch ($response) + { + case Password::INVALID_PASSWORD: + case Password::INVALID_TOKEN: + case Password::INVALID_USER: + return Redirect::back()->with('error', Lang::get($response)); + + case Password::PASSWORD_RESET: + echo 'Password was reset successfully'; + return Redirect::to('login'); + } + } + +} diff --git a/app/controllers/SessionController.php b/app/controllers/SessionController.php new file mode 100644 index 0000000..a4f638b --- /dev/null +++ b/app/controllers/SessionController.php @@ -0,0 +1,55 @@ + 'required|email', + 'password' => 'required|alphaNum|min:3' + ); + + $validator = Validator::make(Input::all(), $rules); + + if ($validator->fails()) { + return Redirect::to('login') + ->withErrors($validator) + ->withInput(Input::except('password')); + } else { + + $userdata = array( + 'email' => Input::get('email'), + 'password' => Input::get('password') + ); + + if (Auth::attempt($userdata)) { + + return \Redirect::to('/'); + + } else { + + return \Redirect::to('login'); + + } + + } + + if (Auth::attempt(array('email' => $email, 'password' => $password), true)) + { + // The user is being remembered... + } + } + + public function doLogout() + { + Auth::logout(); + return \Redirect::to('/'); + } + +} \ No newline at end of file diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php new file mode 100644 index 0000000..b949be1 --- /dev/null +++ b/app/controllers/UserController.php @@ -0,0 +1,120 @@ + 'required|min:3', + 'lastname' => 'required|min:3', + 'email' => 'required|email', + 'password' => 'required|alphaNum|min:3' + ); + + $validator = Validator::make(Input::all(), $rules); + + if ($validator->fails()) + { + return Redirect::to('users/create') + ->withErrors($validator) + ->withInput(Input::except('password')); + } else + { + + //note-to-self: convert to use firstOrCreate(array()) + $firstname = Input::get('firstname'); + $lastname = Input::get('lastname'); + $email = Input::get('email'); + $password = Input::get('password'); + + $user = new User; + $user->firstname = $firstname; + $user->lastname = $lastname; + $user->email = $email; + $user->password = Hash::make($password); + + if($user->save()) + { + return Redirect::to('users/group')->with('success', 'You have successfully registered'); + }else + { + return \Redirect::to('users/create')->with('errors', 'Something terrible happened'); + } + + } + } + + /** + * Display the mentor or mentee choice view + * @return Response + */ + public function chooseGroup() + { + return View::make('mentors.group')->with('id', array()); + } + + /** + * Handles POST to complete user profile + * @param int $id user id + * @return Response + */ + public function completeProfile($id) + { + $user = User::find($id); + + return View::make('mentors.complete', array('user' => $user)); + } + + /** + * Handles POST request to update user profile + * @param $id of the user being updated + * @return Response + */ + public function saveProfile($id) + { + $user = User::find($id); + } + + + /** + * Display the view of a single user + * @param $id user id to be displayed + * @return Response + */ + public function viewProfile($id) + { + $user = User::find($id); + + return View::make('mentors.profile', array('user' => $user)); + } + + + /** + * Display view to edit a given user + * @param $id of the user being updated + * @return Response + */ + public function edit($id) + { + $user = User::find($id); + return View::make('mentors.edit', array('user' => $user)); + } + + + /** + * Handle POST request to delete a user + * @param $id of the user to destroy + * @return Response + */ + public function destroy($id) + { + $user = User::destroy($id); + + } +} \ No newline at end of file diff --git a/app/database/migrations/2014_06_21_195900_create_users_table.php b/app/database/migrations/2014_06_21_195900_create_users_table.php deleted file mode 100644 index 7b03fd0..0000000 --- a/app/database/migrations/2014_06_21_195900_create_users_table.php +++ /dev/null @@ -1,37 +0,0 @@ -increments('id'); - $table->string('name', 32); - $table->string('email', 32); - $table->string('password', 64); - $table->string('title', 32); - $table->string('remember_token', 100)->nullable(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('users'); - } - -} diff --git a/app/database/migrations/2014_06_24_025956_create_user_table.php b/app/database/migrations/2014_06_24_025956_create_user_table.php new file mode 100644 index 0000000..31b5001 --- /dev/null +++ b/app/database/migrations/2014_06_24_025956_create_user_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->string('firstname', 32); + $table->string('lastname', 32); + $table->string('email', 32); + $table->string('password', 64); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('users'); + } + +} diff --git a/app/database/migrations/2014_06_24_031127_alter_user_table_add_token.php b/app/database/migrations/2014_06_24_031127_alter_user_table_add_token.php new file mode 100644 index 0000000..12a8131 --- /dev/null +++ b/app/database/migrations/2014_06_24_031127_alter_user_table_add_token.php @@ -0,0 +1,34 @@ +string('remember_token', 100)->after('password')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + DB::table('users', function(Blueprint $table) + { + $table->dropColumn('remember_token'); + }); + } + +} diff --git a/app/database/migrations/2014_06_24_040438_make_user_email_unique.php b/app/database/migrations/2014_06_24_040438_make_user_email_unique.php new file mode 100644 index 0000000..65e10bb --- /dev/null +++ b/app/database/migrations/2014_06_24_040438_make_user_email_unique.php @@ -0,0 +1,34 @@ +unique('email'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + DB::table('users', function(Blueprint $table) + { + $table->dropUnique('email'); + }); + } + +} diff --git a/app/database/migrations/2014_06_24_042016_create_password_reminders_table.php b/app/database/migrations/2014_06_24_042016_create_password_reminders_table.php new file mode 100644 index 0000000..dfbcf83 --- /dev/null +++ b/app/database/migrations/2014_06_24_042016_create_password_reminders_table.php @@ -0,0 +1,33 @@ +string('email')->index(); + $table->string('token')->index(); + $table->timestamp('created_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('password_reminders'); + } + +} diff --git a/app/database/migrations/2014_06_26_051519_create_mentors_table.php b/app/database/migrations/2014_06_26_051519_create_mentors_table.php new file mode 100644 index 0000000..73144a4 --- /dev/null +++ b/app/database/migrations/2014_06_26_051519_create_mentors_table.php @@ -0,0 +1,31 @@ +increments('id'); + }) + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('mentors'); + } + +} diff --git a/app/database/migrations/2014_06_26_051534_create_mentees_table.php b/app/database/migrations/2014_06_26_051534_create_mentees_table.php new file mode 100644 index 0000000..1d364b1 --- /dev/null +++ b/app/database/migrations/2014_06_26_051534_create_mentees_table.php @@ -0,0 +1,31 @@ +increments('id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('mentees'); + } + +} diff --git a/app/database/seeds/UserTableSeeder.php b/app/database/seeds/UserTableSeeder.php old mode 100755 new mode 100644 index ac7abe4..e7b187a --- a/app/database/seeds/UserTableSeeder.php +++ b/app/database/seeds/UserTableSeeder.php @@ -1,16 +1,16 @@ delete(); User::create(array( - 'name' => 'Elisha Chirchir', - 'email' => 'elisha.java@gmail.com', - 'title' => 'Mentor', - 'password' => Hash::make('admin'), - )); - } + 'firstname' => 'Elisha', + 'lastname' => 'Chirchir', + 'email' => 'elisha.java@gmail.com', + 'password' => Hash::make('admin') + )); + } } \ No newline at end of file diff --git a/app/models/Mentor.php b/app/models/Mentor.php deleted file mode 100644 index f79d39d..0000000 --- a/app/models/Mentor.php +++ /dev/null @@ -1,9 +0,0 @@ - 'login', 'uses' => 'SessionController@showLogin')); +Route::post('login', array('uses' => 'SessionController@doLogin')); +Route::post('logout', array('uses' => 'SessionController@doLogout')); + +/** + * New User Creation Controller routes + */ +Route::get('users/create', array('as' => 'create', 'uses' => 'UserController@create')); +Route::post('users/store', array('uses' => 'UserController@store')); +Route::put('users/{id}/update', array('before' => 'auth', 'as' => 'update', 'uses' => 'UserController@update')); +Route::get('users/{id}/edit', array('before' => 'auth','uses' => 'UserController@edit')); +Route::delete('users/{id}/delete', array('before' => 'auth','uses' => 'UserController@destroy')); +Route::get('users/group', array('uses' => 'UserController@chooseGroup')); +Route::get('users/{id}', array('uses' => 'UserController@viewProfile')); +Route::post('users/{id}', array('uses' => 'UserController@updateProfile')); + +Route::get('choose', function(){ + + return View::make('mentors.group'); + }); -Route::resource('mentors', 'MentorController'); -Route::get('login', array('uses' => 'LoginController@showLogin')); -Route::post('login', array('uses' => 'LoginController@doLogin')); -Route::post('logout', array('uses' => 'LoginController@doLogout')); -Route::get('register', array('uses' => 'LoginController@register')); +/** + * User Password Reminder Controller routes + */ +Route::get('password/remind', array('uses' => 'RemindersController@getRemind')); +Route::post('password/remind', array('uses' => 'RemindersController@postRemind')); +Route::get('password/reset/{token}', array('uses' => 'RemindersController@getReset')); +Route::post('password/reset/{token}', array('uses' => 'RemindersController@postReset')); + +// App::missing(function($exception) +// { +// return View::make('home'); +// }); + + diff --git a/app/views/home.blade.php b/app/views/home.blade.php index aa01839..664b565 100755 --- a/app/views/home.blade.php +++ b/app/views/home.blade.php @@ -2,7 +2,7 @@
-Learn from experts who care to share. When you are ready, be free to give back by sharing your skills with others.
+ +Please use the buttons below to select your category; if you would like to be a Mentor + to someone who is new to your area of expertise, select the Be a Mentor button + and if you would like to find a mentor who will help you through your learning curve, + then select the Be a Mentee button to complete your profile respectively. + Welcome to Mentconnect!
+ +Learn from experts who care to share. When you are ready, be free to give back by sharing your skills with others.
- -