Kyon147 / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
336 stars 99 forks source link

on app reinstall, it started to save empty password (auth token) in database #214

Closed agafonec closed 9 months ago

agafonec commented 10 months ago

Hi There, Recently i updated the domain for the app, but it's suddenly started to save empty password in the user statement in the database. it's happening with 2 of my apps. laravel 9 and laravel 10. any idea what that can be?

Steps to Reproduce

  1. Uninstall the app.
  2. Changed domain for the app.
  3. Changed all domain instances in the app settings, and .env file.
  4. Reinstall app.
  5. checked the database, the password is empty.

Context

Failure Logs

don't see errors in the log.

Thanks in advance.

Kyon147 commented 10 months ago

Are you able to get through the Shopify Oauth probably? Have you also run config:clear and cache:clear just in case?

agafonec commented 10 months ago

Are you able to get through the Shopify Oauth probably? Have you also run config:clear and cache:clear just in case?

Wow, that was a quick reply, thanks. yes i do run config:clear and cache:clear , with sail comand as well. i checked with a custom code if i able to get auth token, it gave me the token. but not with the package. :( but it worked fine a month ago.

Kyon147 commented 10 months ago

In the laravel logs are you seeing an errors? Such as DB ones etc?

agafonec commented 10 months ago

@Kyon147 just tried with complete fresh installation, using blade templating, and only your package installed. went through all installtion process, checked twice. still giving empty password field. https://prnt.sc/WO0Sp_P2mqH2

In the laravel logs are you seeing an errors? Such as DB ones etc?

no, log is completely empty

agafonec commented 10 months ago

@Kyon147 maybe you have advices how can i debug it, and see how authentication process is going?

agafonec commented 10 months ago

@Kyon147 in AuthenticateShop::__invoke() i tried to log like query \Log::info('AUTH CODE', ['query' => $request->query()]); and that's what i got as a result. [2023-09-22 10:06:54] local.INFO: AUTH CODE {"query":{"shop":"astra-collection-store.myshopify.com"}} i assume here should be an auth code. but it's not there, which is weird

Kyon147 commented 10 months ago

I see you are using VUE as the template engine, can you change it to REACT as VUE as a constant is not set up I don't think yet.

agafonec commented 10 months ago

I see you are using VUE as the template engine, can you change it to REACT as VUE as a constant is not set up I don't think yet.

changed it, still the same. here what i found. in the ApiHelper::buildAuthUrl() i logged the generated url, it's giving me the right auth url. but in the database it's still no password again.

  1. i removed the app from the store.
  2. removed the entry from databse.
  3. i simple go with that url that ApiHelper::buildAuthUrl() generated for me.
  4. works perfect, saving the password and everything works fine.

so maybe, there are some problems with redirection? but it would be very common issue, not only me in that case.

Kyon147 commented 10 months ago

Does the issue only happen once you remove the app for the first time?

Do you have the uninstall webhook set up? There are issues if the shop has not been trashed correctly because fields are not set properly. i.e. password should be am empty string and the deleted_at should have a date.

As a fresh install works, that leads me to think it might be that.

agafonec commented 10 months ago

it happened to me even with fresh laravel project, and fresh app created.

speaking about the removed app, i removed an instance from database as well. and then on reinstalling the app, i got the row with the empty password.

Kyon147 commented 9 months ago

@agafonec i've tried to replicate this but can't. if the uninstalled webhook is working as expected then I don't get any problem with reinstalled.

Going to close this for now.

codex5 commented 2 months ago

I got the same issue after removing the app from the store (after removed, the shop record inside users table was still there) Then I tried to reinstall the app and I got empty password. @Kyon147 please help to investigate. You may try to create a new app without any webhooks first, then try to add some webhooks, uninstall and reinstall the app again. Thanks,