Open adamndev opened 1 year ago
@adamndev I'm just getting a project set up so I can test this, will come back to you as quick as I can.
Octane I could not say, as I've not used it or tested it with the package.
Thanks @Kyon147, no rush!
Also, probably important context I forgot to mention - I have a Shop
model that I'm using over the default users
table, but not sure I've seen anywhere to specify this, only the table name for the migrations. I would guess that the error above is because it defaults to the user model. Strange how it's only this scenario though. Thanks for the help!
It could be because you are using a Shop model actually, i'd need to take a look and see if we have hardcoded something that could be throwing the error.
My apps open fine inside the Shopify app but they are also not on blade, so the process is a bit different for SPAs
Hi, I am facing the same issue I am also using a different model for shopify user authentication. this what i changed from the default configuration
in auth.php
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'shopify' => [
'driver' => 'eloquent',
'model' => App\Models\ShopifyShop::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'shopify' => [
'driver' => 'session',
'provider' => 'shopify',
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_reset_tokens',
'expire' => 60,
'throttle' => 60,
],
'shopify' =>[
'provider' => 'shopify',
'table' => 'password_reset_tokens',
'expire' => 60,
'throttle' => 60,
]
],
and my current shopify-app.php
'shop_auth_guard' => env('SHOPIFY_SHOP_AUTH_GUARD', "shopify")
'shop_auth_provider' => env('SHOPIFY_SHOP_AUTH_PROVIDER', 'shopify')
i can see my app install successfully and the shopify user gets populated in the database but it always end up in a Call to undefined method App\Models\User::getSessionContext() error afterward.
If there something I am missing? such as middleware or such?
@adamndev @xiangsgao - can you guys swap back to the default for testing and see if the app loads?
I have resolved my issue. Main problem is line 253 from the VerifyShop.php
$previousContext = $this->previousShop ? $this->previousShop->getSessionContext() : null;
The issue is the middleware is still using the original and default laravel auth guard which uses the user model. rather than my own custom model as you can see in line 133
// Set the previous shop (if available)
if ($request->user()) {
$this->previousShop = $request->user();
}
To fix this, I created my own middleware that runs before this
public function handle(Request $request, Closure $next): Response
{
if (($guard = Util::getShopifyConfig('shop_auth_guard'))) {
$this->auth->setDefaultDriver($guard);
}
return $next($request);
}
I hope this helps anyone who is facing similar issues.
For bug reporting only! If you're posting a feature request or discussion, please ignore.
Expected Behavior
Be able to load the app inside of the Shopify mobile app.
Current Behavior
App throws a 500:
Call to undefined method App\Models\User::getSessionContext()
Failure Information
App loads without issue in a browser, but something is going sideways when loading it in an iframe or whatever context is used within Shopify's mobile app.
Initially thought this might be related to
IframeProtection
in some way, but tried the trick from this issue but the error stays the same.I have Octane running, but I also tried disabling it and there was no change there.
Side question, is Octane likely to function ok considering all of the session/token related bits happening behind the scenes?
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Failure Logs
Please include any relevant log snippets or files here.