API 휴식을 위해 Auth를 수동으로 만들려고 시도하지만 Auth :: 시도에 대한 응답은 항상 false입니다.Laravel manual auth - 작동하지 않음
경로 나 사용자 작성시 암호를 암호화하는 Hash::make
을 userd에 한
class LoginCtrl extends Controller
{
public function checkLogin(Request $request){
$input = $request->all();
if(Auth::attempt(['username' => $input['user'], 'password' => $input['password']])){
$data = ["response"=>true,"access_token"=>"test"];
}else{
$data = ["response"=>false,"access_token"=>"none"];
}
return response()->json($data);
}
}
Route::group(["prefix"=>"api"], function(){
Route::post('/login', [
'as' => 'checkLogin',
'uses' => '[email protected]'
]);
});
컨트롤러.
내 모델입니다 : 내가 잘못 뭐하는 거지
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
protected $table = "usuarios";
protected $username = 'username';
protected $fillable = [
'name', 'username', 'password'
];
protected $hidden = [
//'password', 'remember_token',
];
public $timestamps = false;
public function access_token(){
return $this->hasOne('App\AccessToken');
}
}
? 내 사용자 생성 그게
편집
$user = new User();
$user->username = "myFreshUsername";
$user->password = Hash::make('userPwd');
$user->save();
. 이것이 도움이된다면`php artisan make : auth '를 시작하지 않았습니까? 물론
'\ config \ auth .php'? '$ request-> input()'값을 사용하지 않고 로그인 할 수 있습니까 (예 : \ Auth :: 시도 ([ "사용자 이름"=> "누군가", "비밀번호"=> "비밀번호"])))') –
도 공유 할 수 있습니까? 귀하의 사용자 생성 방법, 그래서 우리는 암호를 암호화로 볼 수 있습니다. 당신이하고있는 암호화 과정이 잘못되었을 수 있습니다. – Qazi
좋아, 나는 사용자 생성 @ Qazi를 게시 할 것이다. Tim 나는'\ config \ auth.php'에서 새로운 laravel 5.2 설치를 변경하지 않았습니다. –