/** * Registration manages the confirmation link sent to the users * who registered for the first time. * ------------------------------------------------------------ * * @method confirm string * */ public function confirm($confirmation_code) { /** * Check for confirmation link with code in the database * if true set the confirmation code field to null and * the confirmed feild to 1 then redirect to login page * else redirect them to login with error message. */ if ($confirmed_code = Userconfirmation::where('confirmation_code', '=', $confirmation_code)->first()) { $user_id = $confirmed_code->user_id; $confirmed_code->user_id = $user_id; $confirmed_code->confirmed = 1; $confirmed_code->confirmation_code = null; $confirmed_code->save(); return Redirect::to('login')->with(array('welcome_back' => 'You have been confirmed please login.')); //return Redirect::to('login')->with(array('confirmed'=>'true','send_to'=>'chooseaccount')); } else { return Redirect::to('login')->with(array('message' => 'The verification link has expired or not correct. <a href="http://popibay.com">Register</a>')); } }
public function login() { $rules = ['email' => 'required|exists:users', 'password' => 'required']; $input = Input::only('email', 'password'); $validator = Validator::make($input, $rules); if ($validator->fails()) { //dd($input); return Redirect::back()->withInput()->with($validator); } $credentials = ['email' => Input::get('email'), 'password' => Input::get('password')]; // check if user is authentic $valid = Auth::validate($credentials); if (!$valid) { //dd($input); return Redirect::back()->withInput()->with(['message' => 'We were unable to sign you in. Incorrect email/password combination!']); } // user is valid, lets check a few things $user = User::where('email', '=', Input::get('email'))->first(); $user_id = $user->id; $get_user_id = Userconfirmation::where('user_id', '=', $user_id)->first(); $user_confirm = $get_user_id->confirmed; // check if user has confirmed their account if ($user_confirm != 1) { return Redirect::back()->withInput()->with(['message' => 'You must confirm your account before you can use your dashboard.']); } // Store your session variables Session::put('pb_user_name', $user->name); Session::put('pb_user_email', Input::get('email')); // incase you decide to use 'Remember me?' checkbox on login $remember = Input::get('remember'); // login the user Auth::login($user, $remember); // redirect to the page they were trying to view, or redirect to index return Redirect::intended('dashboard'); // Use this if you want to redirect to a named route instead // return Redirect::intended(route('home')); }