vendredi 22 mai 2020

api routes showing login page laravel

I'm trying to create an API to authenticate some users for my application. Having a hard time to doing so. My application version is 5.1. When i'm testing my API using POSTMAN, in response it is showing the login page. I am sending a POST request which i excluded from VerifyCsrfToken middleware. In postman header I've set Accept and Content-type as application/json. Now i have no idea why it is showing the login page. Can anyone help me out what i am missing! Thank you

My Routes:

Route::filter('guest', function () {
    if (Auth::check()) {
        return redirect()->route('LoggedIn.Home.OnlineInformation');
    }
});

Route::get('/', function () {
    return redirect()->route('Authentication.GetLogin');
});

Route::get('auth/login', function () {
    return redirect()->route('Authentication.GetLogin');
});

Route::group(array(
    'prefix' => 'Authentication',
    'as' => 'Authentication.'
), function () {
    Route::get('Login', array(
        'uses' => 'AuthenticationController@GetLogin',
        'as' => 'GetLogin'
    ))->before('guest');

    Route::post('ApiLogin', 'AuthenticationController@ApiLogin');
});

AuthenticationController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class AuthenticationController extends Controller {

    public function __construct() {

    }

    public function GetLogin(Request $request)
    {
        $Data = array();
        $Data['PageTitle'] = 'Login';

        return view($this->ViewPagePath . 'GetLogin', $Data);
    }

    public function ApiLogin(Request $request)
    {
        echo "Entered";die;
    }
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36paVLr
via IFTTT

Aucun commentaire:

Enregistrer un commentaire