shaneosullivan/gitmeme

"add new" doesn't work - login loop

Closed this issue · 11 comments

When I click "add new" it says "To add new memes you must be logged in." - but I am. Clicking login the first time, I log in, refresh the page, same behavior. Now clicking "log in" does nothing (because I'm logged in).

chrome and chromium

Apologies for the late reply @jaymzh , is this still an issue for you? Did you try removing the extension and reinstalling?

jrwats commented

I hit this issue just today...

For me clicking "Login" from the plugin or from the inline /meme... UI simply doesn't do anything

Thanks for flagging, I'll look into it soon

jaymzh commented

hey @shaneosullivan - any thoughts?

I couldn't repro when I tried out. I'll try again this weekend

jaymzh commented

Interesting. I can repro on Mac and Linux on Chrome and Chromium.

  • Type /sorrybus
  • Click Add new
  • Click Login
  • Go through OAuth Flow
  • Click Add new again
  • Try to click Login, but nothing happens.
jaymzh commented

I did a tiny bit of debugging tonight...

in getToken.ts, it seems like after getGitHubInfo() returns, something weird happens, because none of the logs within the if get logged, but also, if I add something after the if, it doesn't get logged either:

  getGithubInfo().then(async info => {
    console.log("got github info ", info)
    if (!info.token || !info.id || !info.avatar) {
      console.log("calling launchWebAuthFlow with options", options);
      chrome.identity.launchWebAuthFlow(options, function(
        redirectUri2: string
      ) {
        console.log("launchWebAuthFlow callback with redirect ", redirectUri2);
        if (chrome.runtime.lastError) {
          console.error("launchWebAuthFlow error", chrome.runtime.lastError);
          callback(new Error(chrome.runtime.lastError));
          return;
        }

        // Upon success the response is appended to redirectUri, e.g.
        // https://{app_id}.chromiumapp.org/provider_cb#access_token={value}
        //     &refresh_token={value}
        const matches = redirectUri2.match(redirectRe);

        console.log("matches = ", matches);
        if (matches && matches.length > 1) {
          console.log("calling handleProviderResponse");
          handleProviderResponse(parseRedirectFragment(matches[1]));
        } else {
          callback("Invalid redirect URI");
        }
      });
    }
    console.log("had everything I needed")
  });

That last line never gets logged, but the 'got github info' does, with my info (and it does have an id, token, and avatar).

What's weirder is that none of the things from the Login react component are logged either. Not Logging in nor anything else. I just got back in town and need sleep, but maybe that points you in the right direction.

jaymzh commented

Oh this is because I wasn't re-running yarn build. But also I cannot build it...

$ yarnpkg build
yarn run v1.22.19
$ ../scripts/copy_shared_files.sh && webpack --config webpack/webpack.prod.js && cp src/style.css build
../scripts/copy_shared_files.sh: 1: Bad substitution
Invalid options object. Ignore Plugin has been initialized using an options object that does not match the API schema.
 - options should be one of these:
   object { resourceRegExp, contextRegExp? } | object { checkResource }
   Details:
    * options misses the property 'resourceRegExp'. Should be:
      RegExp
      -> A RegExp to test the request against.
    * options misses the property 'checkResource'. Should be:
      function
      -> A filter function for resource and context.
ValidationError: Invalid options object. Ignore Plugin has been initialized using an options object that does not match the API schema.
    at validate (/home/phil/src/git/gitmeme/extension/node_modules/schema-utils/dist/validate.js:191:11)
    at /home/phil/src/git/gitmeme/extension/node_modules/webpack/lib/util/create-schema-validation.js:16:17
    at new IgnorePlugin (/home/phil/src/git/gitmeme/extension/node_modules/webpack/lib/IgnorePlugin.js:28:3)
    at Object.<anonymous> (/home/phil/src/git/gitmeme/extension/webpack/webpack.common.js:37:5)
    at Module._compile (/home/phil/src/git/gitmeme/extension/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (/home/phil/src/git/gitmeme/extension/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/phil/src/git/gitmeme/extension/webpack/webpack.prod.js:2:16)
    at Module._compile (/home/phil/src/git/gitmeme/extension/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (/home/phil/src/git/gitmeme/extension/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
error Command failed with exit code 1.
jaymzh commented

That bit can be solved with:

diff --git a/extension/webpack/webpack.common.js b/extension/webpack/webpack.common.js
index 32224c4..31638f4 100644
--- a/extension/webpack/webpack.common.js
+++ b/extension/webpack/webpack.common.js
@@ -34,7 +34,7 @@ module.exports = {
   },
   plugins: [
     // exclude locale files in moment
-    new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
+    new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/})
     // new CopyPlugin([{ from: ".", to: "../" }], { context: "public" })
   ]
 };

But then there's a ton more build errors, at least on the latest versions of the requirements.

I've done a bit of work on the extension today, and submitted a new version to the Chrome Web Store. It fixes the login issue and the ability to import a gif from the web. The new version is v1.9, and it'll be released whenever the Google people approve the update

jaymzh commented

I can confirm this fixes the login issue, thanks!

It's still light-gray-on-white for me though. I'll close this and file a bug and screenshot for that.