Hello i have the following routes:
Route::group(['prefix' => '/api/v1/', 'namespace' => 'App\Http\Auth\Controllers'], function() {
/**
* Authentication
*/
Route::controller('auth', 'AuthController');
Route::controller('password', 'PasswordController');
});
And in my AuthController.php
file i have this:
<?php namespace App\Http\Auth\Controllers;
use App\Models\User;
use App\Http\Auth\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;
use App\Http\Auth\Requests\LoginRequest;
use App\Http\Auth\Requests\RegisterRequest;
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
use App\Commands\SendEmail, App\Commands\SendSMS;
use App\Models\CustomerDetails;
use Hash, Session, Auth, DB;
class AuthController extends Controller {
/**
* the model instance
* @var User
*/
protected $user;
/**
* The Guard implementation.
*
* @var Authenticator
*/
protected $auth;
/**
* Create a new authentication controller instance.
*
* @param Authenticator $auth
* @return void
*/
public function __construct(Guard $auth, User $user)
{
$this->user = $user;
$this->auth = $auth;
// Apply the jwt.auth middleware to all methods in this controller
// except for the authenticate method. We don't want to prevent
// the user from retrieving their token if they don't already have it
$this->middleware('jwt.auth', ['except' => ['postRegister', 'postLogin', 'getLogout']]);
}
public function postLogin(LoginRequest $request)
{
...
}
public function getRegister()
{
return [
'method' => 'getRegister'
];
}
public function postRegister(RegisterRequest $request)
{
return [
'method' => 'postRegister'
];
}
Now my issue right now is when i try posting to my postRegister()
method i get a {"error":"token_not_provided"}
exception returned. However when i take out the RegisterRequest $request
it returns 'method' => 'postRegister'
. I have no idea what is going on here and what my request file has to do with jwt auth token, especially since there is no JWT middleware on that route itself but rather inside the controller.
This is my RegisterRequest.php
file:
<?php namespace App\Http\Auth\Requests;
use App\Http\Auth\Requests\Request;
class RegisterRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'fullname' => 'required|min:6',
'phone' => 'required|numeric|min:10',
'email' => 'required|email|unique:users,email',
'password' => 'required|confirmed|min:6'
];
}
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Vnmars
via IFTTT
Aucun commentaire:
Enregistrer un commentaire