xcv58 / meteor-auth0

Auth0 Login Flow for Meteor apps
https://auth0.xcv58.org
MIT License
19 stars 10 forks source link

login after signup does not show the configured widget #11

Open rakesh-agrawal opened 6 years ago

rakesh-agrawal commented 6 years ago

Hi,

We are using the package and having below configuration:

this.signupWithAuth0 = function() { auth0 = initLock({ closable: true,
autoclose: true, loginAfterSignUp: true }); auth0.show(); };

this.loginWithAuth0 = function() { auth0 = initLock({ closable: true, autoclose: true, theme: { logo: Meteor.settings.public.auth0Logo } }); auth0.show(); };

As per our configuration, application will try to login the user after signup. We have also put a rule so that user can login only after email verification.

So as soon as user signs up, our application shows a lock widget to login and gives a message that email verification is pending (as per the Auth0 rule we created). In this widget we do not see our configuration like company logo etc. We see the default lock widget from Auth0.

Where can we configure this? Is this widget is different from the login widget? Ideally it should be same right??

Thanks in Advance.

rakesh-agrawal commented 6 years ago

Any pointers?

xcv58 commented 6 years ago

Just confirm, are you able to see your logo in signup and login widget, but can't see it in the email verification widget?

rakesh-agrawal commented 6 years ago

Yes...

xcv58 commented 6 years ago

I think it's because the package is using the default option to handle Auth0 error. Details in https://github.com/xcv58/meteor-auth0/blob/c542930e635ee6fe53f9602345f829ad8527ceef/auth0-lock/auth0-lock-client.js#L9

Could you please add logs right after your initLock statements to confirm this?

The workflow should be:

  1. User use this.signupWithAuth0 to sign up
  2. Sign up succeed, the page is reloaded with auth0 URL
  3. The package inits a default Lock object to handle auto sign in (auth0 URL from step 2), and find the user email is not verified then popup error widget (without your logo).

Could you please confirm whether my guess is correct and we can discuss solution/workaround for this?

rakesh-agrawal commented 6 years ago

I guess you are absolutely right. In case of error, lock is displayed with default options.

xcv58 commented 6 years ago

Can you try to call initLock in Meteor.startup() with your config? I know it may not work because of the race condition. But it worths a try.

The long-term solution should be not initLock in the package itself and ask the developer to init their own lock object. But it's a breaking change and may need test and warning if developer forgets to init lock.

rakesh-agrawal commented 6 years ago

Ok, We will try to put initlock in startUp. Could you please elaborate what race conditions you are referring.

For the long term solution, I guess it will require changes in the package itself right??

Thanks for helping us!!

xcv58 commented 6 years ago

The race condition is that the default Lock may handle the error before the Lock you init in Meteor.startup().

Yes, the long-term solution requires some changes in the package and will break existing code for someone. But it's just my initial idea, I haven't think about it carefully.

Thank you for reporting the bug and using the package!

rakesh-agrawal commented 6 years ago

Hi,

We have tried putting the lock init in Meteor.startUp(). It works but we are getting another issue 'STATE' DOES NOT MATCH

thanks

xcv58 commented 6 years ago

Could you explain more about 'STATE' DOES NOT MATCH?

rakesh-agrawal commented 6 years ago

This is the error I see on the Auth0 Lock widget and we get this only when we put lock init in Meteor.startUp()

xcv58 commented 6 years ago

This should be the race condition I mentioned. I'm trying to fix it.

rakesh-agrawal commented 6 years ago

Thanks!! We are few days away from our beta release...This fix would help us. Thank You!!

xcv58 commented 6 years ago

Related to https://github.com/auth0/lock/issues/907

rakesh-agrawal commented 6 years ago

ok.. Will it take time to fix?

xcv58 commented 6 years ago

I publish 8.0.0 https://atmospherejs.com/xcv58/auth0-lock with breaking change:

import { Meteor } from 'meteor/meteor';
import { initLock } from 'meteor/xcv58:auth0-lock';
Meteor.startup(function () {
  // This is required to handle login
  const Lock = initLock();
  Lock.show();
})

Could you have a try?

rakesh-agrawal commented 6 years ago

Ok, So upgrading the package should solve this issue. Will upgrade and let you know.. thanks

xcv58 commented 6 years ago

Thanks.

rakesh-agrawal commented 6 years ago

Hi,

I tried upgrading the package. But after upgrade my server is not starting.

Below is the error I am getting: C:\Users\rakesh_agrawal\AppData\Local.meteor\packages\tap_i18n\1.8.2\plugin.tap-i18n-compiler.os\npm\node_modules\meteor\promise\node_modules\meteor-promise\promise_server.js:116 throw error; ^

TypeError: Path must be a string. Received undefined at assertPath (path.js:28:11) at relative (path.js:1262:5) at ImportScanner.getRelativeImportId (C:\tools\isobuild\import-scanner.js:662:24) at each (C:\tools\isobuild\import-scanner.js:632:33) at .each._.forEach (C:\Users\rakesh_agrawal\AppData\Local.meteor\packages\meteor-tool\1.6.1\mt-os.windows.x86_64\dev_bundle\lib\node_modules\underscore\underscore.js:87:22) at ImportScanner.resolve (C:\tools\isobuild\import-scanner.js:621:7) at each (C:\tools\isobuild\import-scanner.js:728:29) at .each._.forEach (C:\Users\rakesh_agrawal\AppData\Local.meteor\packages\meteor-tool\1.6.1\mt-os.windows.x86_64\dev_bundle\lib\node_modules\underscore\underscore.js:87:22) at ImportScanner.scanFile (C:\tools\isobuild\import-scanner.js:719:5) at each (C:\tools\isobuild\import-scanner.js:812:12) at .each._.forEach (C:\Users\rakesh_agrawal\AppData\Local.meteor\packages\meteor-tool\1.6.1\mt-os.windows.x86_64\dev_bundle\lib\node_modules\underscore\underscore.js:87:22) at ImportScanner.scanFile (C:\tools\isobuild\import-scanner.js:719:5) at each (C:\tools\isobuild\import-scanner.js:812:12) at .each._.forEach (C:\Users\rakesh_agrawal\AppData\Local.meteor\packages\meteor-tool\1.6.1\mt-os.windows.x86_64\dev_bundle\lib\node_modules\underscore\underscore.js:87:22) at ImportScanner.scanFile (C:\tools\isobuild\import-scanner.js:719:5) at each (C:\tools\isobuild\import-scanner.js:812:12) at .each._.forEach (C:\Users\rakesh_agrawal\AppData\Local.meteor\packages\meteor-tool\1.6.1\mt-os.windows.x86_64\dev_bundle\lib\node_modules\underscore\underscore.js:87:22) at ImportScanner.scanFile (C:\tools\isobuild\import-scanner.js:719:5) at each (C:\tools\isobuild\import-scanner.js:812:12) at .each._.forEach (C:\Users\rakesh_agrawal\AppData\Local.meteor\packages\meteor-tool\1.6.1\mt-os.windows.x86_64\dev_bundle\lib\node_modules\underscore\underscore.js:87:22) at ImportScanner.scanFile (C:\tools\isobuild\import-scanner.js:719:5) at each (C:\tools\isobuild\import-scanner.js:812:12) at .each._.forEach (C:\Users\rakesh_agrawal\AppData\Local.meteor\packages\meteor-tool\1.6.1\mt-os.windows.x86_64\dev_bundle\lib\node_modules\underscore\underscore.js:87:22) at ImportScanner._scanFile (C:\tools\isobuild\import-scanner.js:719:5) at outputFiles.forEach.file (C:\tools\isobuild\import-scanner.js:414:14) at Array.forEach () at ImportScanner.scanImports (C:\tools\isobuild\import-scanner.js:412:22) at sourceBatches.forEach.batch (C:\tools\isobuild\compiler-plugin.js:1045:17) at Array.forEach () at Function.computeJsOutputFilesMap (C:\tools\isobuild\compiler-plugin.js:1013:19) at ClientTarget.emitResources (C:\tools\isobuild\bundler.js:1057:8) at buildmessage.enterJob (C:\tools\isobuild\bundler.js:828:12) at C:\tools\utils\buildmessage.js:359:18 at exports.EnvironmentVariable.withValue (C:\tools\utils\fiber-helpers.js:89:14) at C:\tools\utils\buildmessage.js:352:34 at exports.EnvironmentVariable.withValue (C:\tools\utils\fiber-helpers.js:89:14) at C:\tools\utils\buildmessage.js:350:23 at exports.EnvironmentVariable.withValue (C:\tools\utils\fiber-helpers.js:89:14) at Object.enterJob (C:\tools\utils\buildmessage.js:324:26) at ClientTarget.make (C:\tools\isobuild\bundler.js:819:18) at C:\tools\isobuild\bundler.js:2929:14 at C:\tools\isobuild\bundler.js:3018:20 at Array.forEach () at Function..each._.forEach (C:\Users\rakesh_agrawal\AppData\Local.meteor\packages\meteor-tool\1.6.1\mt-os.windows.x86_64\dev_bundle\lib\node_modules\underscore\underscore.js:79:11) at C:\tools\isobuild\bundler.js:3017:7 at C:\tools\utils\buildmessage.js:271:13 at exports.EnvironmentVariable.withValue (C:\tools\utils\fiber-helpers.js:89:14) at C:\tools\utils\buildmessage.js:264:29 at exports.EnvironmentVariable.withValue (C:\tools\utils\fiber-helpers.js:89:14) at C:\tools\utils\buildmessage.js:262:18 at exports.EnvironmentVariable.withValue (C:\tools\utils\fiber-helpers.js:89:14) at C:\tools\utils\buildmessage.js:253:23 at exports.EnvironmentVariable.withValue (C:\tools\utils\fiber-helpers.js:89:14) at Object.capture (C:\tools\utils\buildmessage.js:252:19) at bundle (C:\tools\isobuild\bundler.js:2910:31) at files.withCache (C:\tools\isobuild\bundler.js:2857:32) at Object.withCache (C:\tools\fs\files.js:1664:12) at Object.exports.bundle (C:\tools\isobuild\bundler.js:2857:16) at Profile.run (C:\tools\runners\run-app.js:579:36) at Function.run (C:\tools\tool-env\profile.js:490:12) at bundleApp (C:\tools\runners\run-app.js:578:34) at AppRunner._runOnce (C:\tools\runners\run-app.js:622:35) at AppRunner._fiber (C:\tools\runners\run-app.js:880:28) at C:\tools\runners\run-app.js:408:12

Any pointers? My meteor is already at the latest version 1.6.1

xcv58 commented 6 years ago

Delete .meteor/local and try again. The local DB will be deleted as well.

rakesh-agrawal commented 6 years ago

Already tried this.. No success..

Thanks Rakesh


From: Yihong notifications@github.com Sent: Sunday, March 11, 2018 6:53:01 PM To: xcv58/meteor-auth0 Cc: Rakesh Agrawal; Author Subject: Re: [xcv58/meteor-auth0] login after signup does not show the configured widget (#11)

Delete .meteor/local and try again. The local DB will be deleted as well.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xcv58/meteor-auth0/issues/11#issuecomment-372115245, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFV1oBNjjjhpIgtrO-_e_uHKEQXrZRMSks5tdSU0gaJpZM4ScB-p. DISCLAIMER

This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

rakesh-agrawal commented 6 years ago

Removing 8.0.0 and installing 7.1.1 version works fine..

xcv58 commented 6 years ago

I can't reproduce the bug. I did try on different machines.

Could you try to first remove the package, clean up everything not tracked by git under .meteor, then add the latest package again?

The change for 8.0.0 should not lead to this bug: d40c15eb3a0b38f5539b12b63db4f747fef9ef8d

rakesh-agrawal commented 6 years ago

Sure, I will try..

Thanks Rakesh


From: Yihong notifications@github.com Sent: Sunday, March 11, 2018 9:35:50 PM To: xcv58/meteor-auth0 Cc: Rakesh Agrawal; Author Subject: Re: [xcv58/meteor-auth0] login after signup does not show the configured widget (#11)

I can't reproduce the bug. I did try on different machines.

Could you try to first remove the package, clean up everything not tracked by git under .meteor, then add the latest package again?

The change for 8.0.0 should not lead to this bug: d40c15ehttps://github.com/xcv58/meteor-auth0/commit/d40c15eb3a0b38f5539b12b63db4f747fef9ef8d

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xcv58/meteor-auth0/issues/11#issuecomment-372126528, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFV1oPpJTJup1DPDpWJLbWKEXocu2Zg5ks5tdUtegaJpZM4ScB-p. DISCLAIMER

This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

rakesh-agrawal commented 6 years ago

I tried everything, even on a fresh centos machine but it did not work. Do you have an indirect dependency on tap_i18n package?

/home/centos/.meteor/packages/tap_i18n/.1.8.2.pg5k92.3iou++os+web.browser+web.cordova/plugin.tap-i18n-compiler.os/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:116 throw error; ^

TypeError: Path must be a string. Received undefined at assertPath (path.js:28:11)

xcv58 commented 6 years ago

Since I can't reproduce your bug. There is a workaround is you copy the entire fold auth0-lock to your code base, then link it under the packages folder like I did in the example:

https://github.com/xcv58/meteor-auth0/tree/master/examples/sample-app/packages

You can try whether it reproduce the same bug.

Could you also try the sample-app by run meteor --settings production.settings.json to see whether you can reproduce the bug?

rakesh-agrawal commented 6 years ago
Hi,
    Thanks for the suggestions...

    The sample-app you provided worked.

I am trying to replicate the same in my project.
I am not an expert on meteor but I tried the following:

1. Copied auth0-lock folder inside our project code base
2. Created a packages folder inside our project code base.
3. Created xcv58_auth0-lock folder inside the packages folder
4. Created a symlink to the auth0-lock folder

    cd packages/
    ls -ltr
    total 0
    drwxrwxr-x. 3 centos centos 18 Mar 12 07:00 xcv58_auth0-lock
    lrwxrwxrwx. 1 centos centos 13 Mar 12 10:01 xcv58:auth0-lock -> ../auth0-lock

5. Updated packages file under .meteor with xcv58:auth0-lock
6. After that ran meteor -s settings.json
7. I got the error asking to install auth0-lock and auth0 packages
8. I ran meteor npm install --save auth0-lock auth0
9. Now i am getting below error:
    W20180312-15:51:10.564(0)? (STDERR) Error: Cannot find module 'auth0-lock'
    W20180312-15:51:10.564(0)? (STDERR)     at Function.Module._resolveFilename (module.js:538:15)
    W20180312-15:51:10.564(0)? (STDERR)     at Function.resolve (internal/module.js:18:19)
    W20180312-15:51:10.564(0)? (STDERR)     at Object.require (/home/centos/actifiozero/a0-ui-api/.meteor/local/build/programs/server/boot.js:288:32)
    W20180312-15:51:10.565(0)? (STDERR)     at makeInstallerOptions.fallback (packages/modules-runtime.js:651:18)
    W20180312-15:51:10.565(0)? (STDERR)     at require (packages/modules-runtime.js:244:16)
    W20180312-15:51:10.565(0)? (STDERR)     at auth0-lock-client.js (auth0-lock/auth0-lock-client.js:1:228)
    W20180312-15:51:10.565(0)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:343:9)
    W20180312-15:51:10.565(0)? (STDERR)     at require (packages/modules-runtime.js:238:16)
    W20180312-15:51:10.566(0)? (STDERR)     at /home/centos/actifiozero/a0-ui-api/.meteor/local/build/programs/server/app/app.js:3770:1

Am i missing anything?
xcv58 commented 6 years ago

You can actually copy the auth0-lock folder into your packages and rename to xcv58:auth0-lock.

So eventually your meteor has packages/xcv58:auth0-lock/ with the files in auth0-lock.

rakesh-agrawal commented 6 years ago

Thanks it worked..