Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending ApiGuardController #113

Open
cascornelissen opened this issue Mar 29, 2016 · 3 comments
Open

Extending ApiGuardController #113

cascornelissen opened this issue Mar 29, 2016 · 3 comments

Comments

@cascornelissen
Copy link

I'm trying to extend the ApiGuardController to allow for disabling the feature during development (based on APP_DEBUG) and "global" request limiting. It works just fine but I'm thinking about features that will be executed based on the validity of the key (e.g. e-mail notifications) but ApiGuardAuth::isAuthenticated() always returns false.

I'm extending the following custom controller in my own controllers.

<?php

namespace App\Http\Controllers;

use \Chrisbjr\ApiGuard\Http\Controllers\ApiGuardController;

use Config;
use ApiGuardAuth;

class ApiController extends ApiGuardController {
    protected $apiMethods;

    public function __construct() {
        // Disable API key authentication on development environments
        if ( !env('APP_DEBUG') ) {
            parent::__construct();
            $this->apiMethods = Config::get('api.api-guard');
            // var_dump(ApiGuardAuth::isAuthenticated());
        }
    }
}

Why is it returning false and what would be the best way to determine whether the current request has a valid key?

Another (probably relevant) question I'm having is how to change the error object (GEN-UNAUTHORIZED a.o.) that gets returned?

@cascornelissen
Copy link
Author

@chrisbjr, any thoughts or updates on this?

@morganzysman
Copy link

I'm interested in doing that too.
I has doing class ApiController extends ApiGuardController with the version two without any problem.

I'm now working on a new projet, and I'm not able to use $this->user when extending ApiGuardController nor the apiMethodes seem to be working.

@rmdwirizki
Copy link

Same here.. Simply calling $apiMethods in the extended controller always return null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants