2015-01-09 2 views
2

내가 Larave에 새로운 오전과 내가, 내가이 문제에 대해 많은 검색 작동하지 로그인 양식을 만들어 내가 나를 위해 작동하지 않는 이러한 질문에 대한 답변 발견Laravel 인증이 작동하지 true를 반환하지

  1. Question 1
  2. Question 2
  3. Question 3

나는이 3 개 질문을 읽고 다시 작동하지 :

|

ID :

이 내 사용자 테이블 사용자 이름 | 비밀 번호 | remember_token | created_at | updated_at

1 | [email protected] | 이 내 길이다

<?php 
use Illuminate\Auth\UserTrait; 
use Illuminate\Auth\UserInterface; 
use Illuminate\Auth\Reminders\RemindableTrait; 
use Illuminate\Auth\Reminders\RemindableInterface; 
class User extends Eloquent implements UserInterface, RemindableInterface { 
    use UserTrait, RemindableTrait; 
    public static $auth_rules=[ 
     'email'=>'required|email', 
     'password'=>'required|between:3,18' 
    ]; 
    protected $hidden = array('password', 'remember_token'); 
} 

:

Route::group(array('prefix'=>'admin','before'=>'Auth'),function(){ 
    Route::resource('posts','AdminPostsController', array('except'=>array('show'))); 
}); 

이 필터입니다 (인증) :

Route::filter('Auth', function() 
{ 
    if (Auth::guest()) 
    { 
     if (Request::ajax()) 
     { 
      return Response::make('Unauthorized', 401); 
     } 
     else 
     { 
      return Redirect::guest('admin/login'); 
     } 
    } 
}); 
012,341,462 testpass1이 내 사용자 모델

입니다 이것은 AdminAuthController 그 경로가 AdminAuthController의 @의 postLogin에 로그인 데이터를 보낼 수 있습니다 : http://i.stack.imgur.com/9cq61.png

+0

가능한 중복 [Laravel 인증 :: 시도() 항상 false?] (http://stackoverflow.com/questions/18006597/laravel-authattempt-always-false) –

+0

@MattBurrow 예 나는 그것을 보지 못했습니다. 감사합니다 –

답변

1

테이블에있는 암호가 필요 가 을 할 수있는이 브라우저에 반환 Laravel 무엇

//This is postLogin method: 
    public function postLogin(){ 
    //Showing username and password 
     echo 'Username:'.Input::get('email').'<br/>'; 
    echo 'Password:'.Input::get('password').'<br />'; 

    //If username and password: return true 
    dd(Auth::attempt(array('username'=>Input::get('email'),'password'=>Input::get('password') ))); 
    } 

해시!

Hash::make('password')을 사용하여 암호의 해시를 생성 할 수 있습니다. 수동으로 개발하여 DB를 업데이트하려면 신속 해시를 생성하는 artisan tinker를 사용할 수 있습니다

php artisan tinker 
> echo Hash::make('your-secret-password'); 

복사 출력하여 DB에 암호 필드를 업데이트합니다.

참고 DB를 필드가 적어도 60 자까지 입력 할 필요가

+0

출력을 복사하고 암호 필드를 업데이트 하시겠습니까? –

+0

예. 출력은 다음과 같이되어야합니다 :'$ 2y $ 10 $ xdWRiQr6TQxj/4Ll/6iAfeTYcsVrH1MwvFpNLz3dpX/8M3t8h1W42' – lukasgeiter

+0

정말 고마워요. 나는 네가 최고라고 생각한다. Stackoverflow에게 내가 선택한 마법 답변 인 녹색 마법 버튼을 틱하게됩니다 –

관련 문제