Forgot Password Plugin with Local Deployment


#1

Hello Skygear Team,

Are there any guides for setting up the forgot password plugin on a locally deployed Skygear server using Javascript?

Do I need to set it up as a plugin using docker-container, or can I just call skygear.auth.forgotPassword()?

Thanks for your help!


#2

Hi there,

To call skygear.auth.forgotPassword(), you will need to have the forgotPassword plugins properly setup on the server if you deploy locally.

The README on the repo should be pretty comprehensive. Let me know if you have any specific question?

BTW, I think it is a good idea to include a sample docker-compose to configure all plugins on skygear.io, just created an issue:


#3

Hey @bencheng,

Thanks for your help so far. I have the forgot password plugin running in a container along side of my skygear-server now, but when I call skygear.auth.forgotPassword(email), I get an error message like this:

{\"error\":{\"name\":\"UnexpectedError\",\"code\":10000,\"message\":\"(\\"No table of name '{}' exists in schema '{}'.\\", '_user', 'app_boilerplate')\",\"info\":{\"trace\":\"Traceback (most recent call last):\n  File \\"/usr/local/lib/python3.5/site-packages/skygear/utils/db.py\\", line 100, in get_table\n    return _get_metadata().tables[_full_table_name(schema_name, name)]\nKeyError: 'app_boilerplate._user'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \\"/usr/local/lib/python3.5/site-packages/skygear/transmitter/common.py\\", line 40, in wrapper\n    return dict(result=f(self, *args, **kwargs))\n  File \\"/usr/local/lib/python3.5/site-packages/skygear/transmitter/common.py\\", line 100, in call_func\n    return self.op(obj, param.get('args', {}))\n  File \\"/usr/local/lib/python3.5/site-packages/skygear/transmitter/common.py\\", line 174, in op\n    return func(*args, **kwargs)\n  File \\"forgot_password/handlers/forgot_password.py\\", line 72, in forgot_password\n    user = user_util.get_user_from_email(c, email)\n  File \\"forgot_password/handlers/util/user.py\\", line 78, in get_user_from_email\n    users = get_table('_user')\n  File \\"/usr/local/lib/python3.5/site-packages/skygear/utils/db.py\\", line 103, in get_table\n    name, schema_name)\nException: (\\"No table of name '{}' exists in schema '{}'.\\", '_user', 'app_boilerplate')\n\"}}}

app_boilerplate is the APP_NAME right now. From looking at the way that the users table is queried during login/signup, it seems to me that the name of the users table should be user instead of _user. Maybe this is what is causing the problem?

My forgot-password.yml file is below, which is built along with the docker-compose.yml file for my skygear-server. APP_NAME, API_KEY, and MASTER_KEY are being passed down from docker-compose.yml.

version: '2'

services:

  app:
    environment:
      FORGOT_TRANSPORT: zmq
      FORGOT_PATH: forgot
      FORGOT_ARGS: tcp://0.0.0.0:5555

  forgot-password:
      build: https://github.com/SkygearIO/forgot_password.git

      environment:
        DATABASE_URL: "${DATABASE_URL}"
        SKYGEAR_ADDRESS: tcp://app:5555
        APP_NAME: 
        API_KEY: 
        MASTER_KEY:
        LOAD_MODULES: forgot_password
        
        PUBSUB_URL: "ws://app:${SKYGEAR_PORT}/pubsub"
        SKYGEAR_ENDPOINT: "http://app:${SKYGEAR_PORT}"
              
        FORGOT_PASSWORD_APP_NAME: "${APP_NAME}"
        FORGOT_PASSWORD_URL_PREFIX: "http://app:${SKYGEAR_PORT}"
        FORGOT_PASSWORD_SENDER: test_email@gmail.com
        FORGOT_PASSWORD_SUBJECT: Forgot Password
        
        SMTP_HOST: smtp.gmail.com

Any idea what might be causing the issue looking up the users table in Skygear? Thanks again for your help so far.


#4

#5

@rickmak Probably knows better?


#6

Hi @Adam_Stone,

This bug is know before, and fix at py-skygear master and deployed to http://portal.skygear.io/. refs: https://github.com/SkygearIO/forgot_password/issues/23

You still hit this bugs because of the fix is not released to pypi. To solve your problem, I just push a minor release py-skygear v1.1.1. refs: https://pypi.python.org/pypi/skygear/1.1.1

Re-create your docker container should fetch the latest official images.

Let me know if there is still problem.

Best,
Rick


#7

Hey @rickmak,

I apologize for the late reply. The fix that you pushed worked once I rebuilt my Docker container. Thanks so much!