2017-02-24 12 views

答えて

0

ここで彼に私のコード

public function dologin() { 

    $input = Input::all(); 

    $rules = [ 
     'username' => 'required', 
     'password' => 'required|min:6', 
    ]; 
    $validator = Validator::make($input, $rules); 

    if ($validator->fails()) { 

     Alert()->info('Username dan password tidak boleh kosong Panjang Password minimal 6 huruf', 'Info')->persistent('OK'); 
     return redirect()->route('auth.login'); 

    } else { 
     $user = CoreUser::where('username', $input['username'])->orWhere('user_email', $input['username'])->first(); 

     if ($user) { 

      if($user->user_active != 1){ 
       Alert()->error('Username sudah tidak aktif', 'Info')->persistent('OK'); 
       return redirect()->route('auth.login')->withErrors("User tidak aktif"); 

      } 
      if (Hash::check($input['password'], $user->password)) { 
       $session = [ 
        'username' => $user->username, 
        'password' => $input['password'] 
       ]; 
       $remember = true; 
       if (Auth::attempt($session, true)) { 

        return redirect()->intended('/'); 
       } else { 
        // no action 
        dd("failed attempt"); 
       } 
      } else { 

       //dd("hash check failed"); 
       // no action 
      } 
     } 
     Alert()->error('Username dan password tidak sesuai', 'Gagal')->persistent('OK'); 
     return redirect()->route('auth.login')->withErrors("Invalid Username or Password"); 
    } 
} 
関連する問題