getting wrong user with laravel sanctum - laravel-sanctum

I am using Laravel Sanctum to provide a personal access token to my clients.
I am using these guards in auth.php:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'client' => [
'driver' => 'token',
'provider' => 'clients',
'hash' => false
]
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'clients' => [
'driver' => 'eloquent',
'model' => App\Models\Client::class,
],
],
I give my clients tokens using the following code:
$client = Client::find($id);
$token = $client->createToken('CLIENT_TOKEN');
but whenever I try to access the user with $request->user() I get the wrong user. while the token is completely different from what the retrieved user is.
I am using laravel-swoole package as my webserver.

Related

How to connect magento 2 to Redis

I have a magento 2 installation on docker, i would like to work with redis api, but not for magento2's session or page caching.
I would like to use the get() and set() commands to store strings, hash tables and many more.
Majorly what i need is a way to connect to a redis installed on docker instance that is on the same network as a magento 2 installation which is also on docker.
Thanks in advance.
I'm using Redis docker, maybe this will help you:
'session' => [
'save' => 'redis',
'redis' => [
'host' => 'redis',
'port' => '6379',
'password' => '',
'timeout' => '2.5',
'persistent_identifier' => '',
'database' => '0',
'compression_threshold' => '2048',
'compression_library' => 'gzip',
'log_level' => '1',
'max_concurrency' => '10',
'break_after_frontend' => '5',
'break_after_adminhtml' => '30',
'first_lifetime' => '600',
'bot_first_lifetime' => '60',
'bot_lifetime' => '7200',
'disable_locking' => '1',
'min_lifetime' => '60',
'max_lifetime' => '2592000'
]
],
'cache' => [
'frontend' => [
'default' => [
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' => [
'server' => 'redis',
'database' => '1',
'port' => '6379'
]
]
]
],
Regards

How to send messages using AWS Pinpoint service using PHP SDK

Hi I am trying to send a message using AWS Pinpoint with the PHP SDK, but I am getting an error. Any ideas why? Here is my code:
$client = new PinpointClient([
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => [
'key' => 'MYIAMAWSKEY',
'secret' => 'MYAWSSECRET',
]
]);
$result = $client->sendMessages([
'ApplicationId' => 'MyAppId',
'MessageRequest' => [
'Addresses' => [
'AnIOSDeviceToken' => [
'BodyOverride' => 'aaa',
'ChannelType' => 'APNS',
'RawContent' => 'bbb',
'Context' => ['ccc' => '222'],
'TitleOverride' => 'ddd',
],
],
],
'MessageConfiguration' => [
'APNSMessage' => [
'Action' => 'OPEN_APP',
'Body' => 'Hello',
'RawContent' => 'World',
'SilentPush' => false,
'Title' => 'Hello World!!!',
],
],
]);
I get the following error:
DeliveryStatus: 'PERMANENT_FAILURE'
StatusCode: 400
StatusMessage: Invalid notification: Notification is malformed
According to the API Docs, 'MessageConfiguration' needs to be inside the 'MessageRequest' field. Please make sure your input parameters fully match the documented API Parameter Syntax.

ZF2/3 catchall route with slug

I need one route to fetch page content out of my CMS by a slug. I thought I could easy create a configuration like the following but it seems that it only works with multiple parts in the route. My plan was to create a custom route, but if I don't get a match with the system routes I don't think I will get one with my custom route :)
So is there a way to do that?
Does not work
'router' => [
'routes' => [
'cms' => [
'type' => \Zend\Router\Http\Segment::class,
'options' => [
'route' => '/:slug',
'defaults' => [
'controller' => \Cms\Controller\PageController::class,
'action' => 'index'
]
]
]
]
];
Works
'router' => [
'routes' => [
'cms' => [
'type' => \Zend\Router\Http\Segment::class,
'options' => [
'route' => '/test/:slug', // <-- Here is the change
'defaults' => [
'controller' => \Cms\Controller\PageController::class,
'action' => 'index'
]
]
]
]
];
OK, forgett everything... I already had a segment route with the same format, but with some constraints. Therefore I got a 404 page. So everything works fine...

How to update groupings via Mailchimp API?

I'm trying to subscribe and update members of a Mailchimp list from my Rails 3.2 app via the API.
Everything is working fine, except that I am unable to set interest groups.
What is the correct format for setting groupings.
I've tried
merge_vars: 'GROUPINGS' => [
[
'id' => group_id,
'groups' => ['array', 'of', 'groups']
]
]
and
merge_vars: 'GROUPINGS' => [
[
'id' => group_id,
'groups' => "comma,separated,groups"
]
]
and
merge_vars: 'GROUPINGS' => [
0 => [
'id' => group_id,
'groups' => "comma,separated,groups"
]
]
and several other variations.
Nothing seems to work and the docs are unclear
Took me some time but I finnaly figured out the correct format :
#gb.lists.subscribe({:id => list_id,
:email => {:email => self.email},
:merge_vars => {:FNAME => self.firstname,
:groupings => [{:id => grouping_id,
:groups => ["name","of","groups"]
}]
},
:double_optin => false,
:send_welcome => false,
:update_existing => true})
I'm using rails 3.1.11 and gibbon 0.5.0
Hope this will help !

Unable to override route via DI

I'm attempting to override the routes provided by ZfcUser using akrabat's method, however it doesn't seem to have any effect. I'm starting by rebasing the routes from /user to /users but will want to add other routes later on (should be simple if I can get this working).
My DI configuration:
return [
'di' => [
'instance' => [
'Zend\Mvc\Router\RouteStack' => [
'parameters' => [
'routes' => [
'zfcuser' => [
'options' => [
'route' => '/users'
]
]
]
]
]
]
]
];
Am I making an obvious mistake or has the configuration structure for this changed since this blogpost?
You'd overwrite configuration from within your own modules.
'router' => array(
'routes' => array(
'zfcuser' => array(
//...
)
)
)
Though if i'm correct the full DI Path should still work... It's important, too, that your module loads AFTER the zfcUser-Module. So within your application.config.php be sure that your modules Namespace is listed after zfcUser. Since the arrays simply get overwritten depending on load time ^^

Resources