2017-05-24 13 views
0

전자 메일 및 암호 외에도 로그인하는 동안 확인 된 추가 열을 검사했습니다. 나는 그것은 지금 일하고있어 아래 보호 기능 자격 증명 (요청 $ 요청)추가 열 laravel 인증 로그인 확인

{ 
    //return $request->only($this->username(), 'password'); 
    $credentials = $request->only('email', 'password'); 
    $credentials = array_add($credentials, 'verified', '1'); 
    return $credentials; 
} 

처럼 AuthenticatesUser.php으로 변경했다. 이메일과 비밀번호가 일치하지만 확인 = 0 인 경우 확인되지 않은 오류 메시지를 보내려고합니다.

답변

0

UserController.php

public function doLogin(){ 

     // validate the info, create rules for the inputs 
     $rules = array(
      'email' => 'required|email', // make sure the email is an actual email 
      'password' => 'required|alphaNum|min:6' // password can only be alphanumeric and has to be greater than 6 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('user/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 
       // check if verified 
        $user = Auth::getLastAttempted(); 
        if ($user->confirmed==1) { 
         return Redirect::to('user/dashboard'); 
        } 
        else{ 
         Auth::logout(); 
         return redirect('user/login')->with('flash_msg','Your account is not verified. Check your email for further process.')->withInput(Input::except('password')); 
        } 
       } else {   
       // validation not successful, send back to form 
        return redirect('user/login')->with('error_msg','Invalid login information, try again')->withInput(Input::except('password')); 
       } 
      } 
     }