Auth0 Login ServiceProvider - laravel

I follow up this tutorial using Laravel 5.4 Creating your first Laravel app and adding authentication
But I can't retrieve Auth0 users, the registration works fine in my dashboard new users are created in Auth0 server, but not in my local database and also I can't dd(Auth0::getUser());
I get this error:
Class 'Auth0\Login\LoginServiceProvider' not found
I've added this
Auth0\Login\LoginServiceProvider::class
in my provider array and
'Auth0' => Auth0\Login\Facade\Auth0::class
in my aliases.
I did all steps on configuration from Auth0 docs: Auth0 PHP (Laravel) SDK
I'm out off option now!

Ok, figure it out now.
The error was coming from 'AppServiceProvider.php'
Just import those two classes in AppServiceProvider.php as:
use Auth0\Login\Contract\Auth0UserRepository as Auth0UserRepositoryContract;
use Auth0\Login\Repository\Auth0UserRepository as Auth0UserRepository;
And then your Register method should look like this:
public function register()
{
$this->app->bind( Auth0UserRepositoryContract::class, Auth0UserRepository::class );
$this->app->bind( Auth0UserRepositoryContract::class, Auth0UserRepository::class );
}
if you want to persist data in your database then Create your own Repository and update the bind method YourCustomerRepositoryContract::class, YourCustomerRepository::class
Just like that.
For more info about creating your own Repository
Auth0 PHP (Laravel) SDK Quickstarts: Login

Related

Target [Laravel\Fortify\Contracts\ResetsUserPasswords] is not instantiable

I am implementing the forgot password / password reset logic with Laravel 8 and Fortify for an SPA application.
When the /reset-password is called and if the data are all correct (email, password, password_confirmation, token), I get a server side error:
Target [Laravel\Fortify\Contracts\ResetsUserPasswords] is not instantiable.
The route is defined as follows in api.php:
Route::post('/reset-password', [NewPasswordController::class, 'store']);
Thanks for your help
I had the same issue in my API and I was able to resolve it.
Target [Laravel\Fortify\Contracts\ResetsUserPasswords] is not instantiable.
Laravel\Fortify\Contracts\ResetsUserPasswords is an interface, and Fortify (by default) has implemented the ResetsUserPassword Action which implements the interface.
All you need to get it working is to ensure this class App\Providers\FortifyServiceProvider::class is registered within the providers array of your application's config/app.php configuration file.
// ...
App\Providers\FortifyServiceProvider::class,
You need to register views, thats why this error is throwing. I was able to fix the issue by doing this.
Document: https://laravel.com/docs/8.x/fortify#registration
Please check this thread: target [Laravel\Fortify\Contracts\RegisterViewResponse] is not instantiable
Fortify::registerView(function () {
return view('auth.register');
});

Bitcoind walletnotify configure on Laravel does not work

I have successfully configured bitcoind and connected it from a Laravel application. My issue now is walletnotify does not get triggered when a new transaction comes on an internally generated address.
bitcoin.conf
maxconnections=12
rpcuser=user
rpcpassword=pass
test.rpcport=18332
rpcallowip=0.0.0.0/0 --testing purposes
keypool=10000
server=1
testnet=1
txindex=1
walletnotify=/usr/bin/curl http://127.0.0.1/notify/%s
I have also tried with:
walletnotify=curl http://127.0.0.1/notify/%s
The route:
Route::get('/notify', 'HomeController#notify');
The Controller:
public function notify($tx) {
$txinfo = Bitcoind::getRawTransaction($tx, true);
$txinfo = $txinfo->get();
.....
}
Notes:
Blockchain is synced.
I have checked the debug.log from bitcoin but no errors from walletnotify or at least the curl when it should run.
If I manually call the route and pass a txid, everything goes well.
Thanks in advance for any help!
Problem solved!
WalletNotify config below works just fine.
walletnotify=curl http://127.0.0.1/notify/%s
The problem was I build the function that verifies the transaction in the HomeController, which is guarded by the AUTH middleware. As I started this for testing purposes, I forget about the guard from the HomeController which is created by laravel authentication scaffolding.

No notifications are returned

I am trying to get user's unread notifications though my controller.
This works:
public function notifications(){
return \App\User::find(auth()->user()->id)->unreadNotifications()->limit(5)->get();
}
This doesn't, it returns an empty collection:
public function notifications(){
return auth()->user()->unreadNotifications()->limit(5)->get();
}
Could you tell me what I am missing? Thanks in advance.
Using Laravel 5.8 with Backpack 3.5.
The default auth guard of Laravel is overwitten to use Backpack auth in backpack routes, using the UseBackpackAuthGuardInsteadOfDefaultAuthGuard middleware of the permissions manager package. In the rest of the controller auth() and backpack_auth works normally.
Try this:
public function notifications()
return Auth::user()->unreadNotifications()->limit(5)->get();
}
As said in the docs:
You may access the authenticated user via the Auth facade:
Alternatively, once a user is authenticated, you may access the authenticated user via an Illuminate\Http\Request instance. Remember, type-hinted classes will automatically be injected into your controller methods:
Auth and auth() likely don't work here because you're using the Backpack For Laravel authentication which uses a different guard than the default one Laravel uses.
This would probably work for you:
backpack_user()->unreadNotifications()->limit(5)->get();
If that works, here's why:
If you take a look at project/vendor/backpack/base/src/helpers.php you'll see that backpack_user() is an alias for backpack_auth()->user() and backpack_auth does a:
return \Auth::guard(backpack_guard_name());
That's the important bit because it grabs the guard defined config/backpack/base.php (which is backpack by default) and uses that instead of Laravel's default guard of web.

Laravel and GraphQL : How to use Passport of Laravel for Authentication when using laravel-graphql?

I want to use GraphQL in Laravel,I chose the package laravel-graphql ,my question is:
How to use Passport of Laravel for Authentication when using laravel-graphql?
I haven't used the package myself before, but from looking at the code I would say you can add a middleware in the configuration file config/graphql.php that performs the authentication and/or permission check:
/*
* Any middleware for the 'graphql' route group
*/
'middleware' => ['auth:api'], // or 'auth' for normal authentication
If this doesn't work for you, there is also the possibility to override the controller used by the package. The configuration for this is also in the same configuration file. You could for example extend the existing controller to achieve what you want. Or you write an entirely new one.
at first you have to install laravel passport step by step after install passport then you have to use
#middleware(checks:["auth:api"])
in schema.graphql file

OAuth Not Working With Laravel

i am trying to connect my magento 2.0 store from my laravel application, when i make OAuth call from laravel to my magento 2.0 store laravel throws an error Class 'OAuth' not found.
OAuth is installed on my system and code works perfectly out side laravel but when i place code inside of a Laravel controller it throws the error
following is my code of OAuth call that i am making from laravel
$oAuth = new OAuth($integratoinData->auth_data->consumer_key, $integratoinData->auth_data->consumer_secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
$oAuth->setToken($integratoinData->auth_data->access_token, $integratoinData->auth_data->access_token_secret);
$oAuth->fetch($integrationCredentials['url']);
$responseInfo = $oAuth->getLastResponseInfo();
please help me thank you in advance
Try adding '\' when making instance of OAuth:
$oAuth = new \OAuth($integrato...

Resources