Open edX ecommerce URL not working

Hi
After installing tutor using a precompile binary, I have enabled ecommerce plugin using tutor plugins enable discovery ecommerce.
According to the tutor plugins list both plugins are enabled but when I try to go to http://ecommerce.local.overhang.io/ it gets redirected to the dashboard page.
the output of the tutor local logs -f --tail=10 command is:

nginx_1             | 192.168.7.22 - - [29/Nov/2020:08:16:08 +0000] "GET / HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" "-"
nginx_1             | 192.168.7.22 - - [29/Nov/2020:08:16:08 +0000] "GET /dashboard/ HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" "-"
lms_1               | 2020-11-29 08:16:08,962 INFO 213 [tracking] [user 3] logger.py:49 - {"host": "local.overhang.io", "event_type": "/dashboard", "context": {"user_id": 3, "org_id": "", "path": "/dashboard", "course_id": ""}, "agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36", "event": "{\"POST\": {}, \"GET\": {}}", "accept_language": "en-US,en;q=0.9,fa;q=0.8", "event_source": "server", "ip": "192.168.7.22", "referer": "", "time": "2020-11-29T08:16:08.962540+00:00", "username": "admin", "page": null}
lms_1               | 192.168.7.22 - - [29/Nov/2020:08:16:09 +0000] "GET /dashboard HTTP/1.0" 200 16043 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36"
nginx_1             | 192.168.7.22 - - [29/Nov/2020:08:16:09 +0000] http://local.overhang.io "GET /dashboard HTTP/1.1" 200 16043 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" "-"

Are there any other configurations that I’m missing?

Did you run tutor local quickstart?

Yes. According to https://pypi.org/project/tutor-ecommerce/ I ran tutor local quickstart after enabling the plugins.
Related docker containers are also running. Here is the output of the docker ps command:

CONTAINER ID        IMAGE                                        COMMAND                  CREATED             STATUS              PORTS                                                 NAMES
23b7378c0963        overhangio/openedx-ecommerce-worker:10.1.6   "/bin/sh -c 'celery …"   18 hours ago        Up 4 hours                                                                tutor_local_ecommerce-worker_1
17e70ec7cfc9        overhangio/openedx-ecommerce:10.1.6          "/bin/sh -c 'gunicor…"   18 hours ago        Up 4 hours          8000/tcp                                              tutor_local_ecommerce_1
a4318065de88        nginx:1.13                                   "nginx -g 'daemon of…"   18 hours ago        Up 4 hours          0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp              tutor_local_nginx_1
bde5edd1f47d        overhangio/openedx:10.4.0                    "docker-entrypoint.s…"   18 hours ago        Up 4 hours          8000/tcp                                              tutor_local_cms-worker_1
067a7a61dcec        overhangio/openedx-discovery:10.1.7          "/bin/sh -c 'gunicor…"   18 hours ago        Up 4 hours          8000/tcp                                              tutor_local_discovery_1
e96a91da10d5        overhangio/openedx:10.4.0                    "docker-entrypoint.s…"   18 hours ago        Up 4 hours          8000/tcp                                              tutor_local_cms_1
2fec796d514c        overhangio/openedx:10.4.0                    "docker-entrypoint.s…"   18 hours ago        Up 4 hours          8000/tcp                                              tutor_local_lms-worker_1
f8c5d90ac998        overhangio/openedx:10.4.0                    "docker-entrypoint.s…"   18 hours ago        Up 4 hours          8000/tcp                                              tutor_local_lms_1
e1f47d01eaa6        overhangio/openedx-forum:10.4.0              "docker-entrypoint.s…"   18 hours ago        Up 4 hours          4567/tcp                                              tutor_local_forum_1
ac36b08656e0        rabbitmq:3.6.10-management-alpine            "docker-entrypoint.s…"   18 hours ago        Up 4 hours          4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   tutor_local_rabbitmq_1
c92ecf794b3d        elasticsearch:1.5.2                          "/docker-entrypoint.…"   18 hours ago        Up 4 hours          9200/tcp, 9300/tcp                                    tutor_local_elasticsearch_1
ac41804e5915        namshi/smtp:latest                           "/bin/entrypoint.sh …"   18 hours ago        Up 4 hours          25/tcp                                                tutor_local_smtp_1
7d5f8f010d45        mongo:3.6.18                                 "docker-entrypoint.s…"   18 hours ago        Up 4 hours          27017/tcp                                             tutor_local_mongodb_1
2fe63e820d82        mysql:5.6.49                                 "docker-entrypoint.s…"   18 hours ago        Up 4 hours          3306/tcp                                              tutor_local_mysql_1
a22df378aee1        memcached:1.4.38                             "docker-entrypoint.s…"   18 hours ago        Up 4 hours          11211/tcp                                             tutor_local_memcached_1

Are you getting redirected to the dashboard page because you are logged-in to the LMS with a non-staff user?

Actually I’m logged in as admin user.
Even when I’m not logged-in, I get redirected to login page.

This is surprising. How did you create the admin user? Did you modify any configuration variable?

using the official document’s method:
tutor local createuser --staff --superuser yourusername user@email.com

No. I have followed the standard installation procedure and then enabled xqueue, discovery and ecommerce plugins.

OK, good news is that I managed to reproduce the issue on a new installation. I guess I didn’t detect it earlier because I always create a super user in ecommerce directly. I’ll be able to investigate this.

I finally remembered something: this is not a bug, it’s actually a feature :sweat_smile: Users who are staff/superusers on the LMS do not necessarily have the same privileges in Ecommerce. You need to explicitly grant superuser/staff privileges with the createsuperuser command, as indicated in the README.

To grant staff+superuser access to an existing user, run:

tutor local run ecommerce ./manage.py shell -c "from django.contrib.auth import get_user_model; get_user_model().objects.filter(email='USER@EMAIL.COM').update(is_staff=True, is_superuser=True)"

I’ll add this information to the Readme.

2 Likes

After running the above command, I can’t access the LMS anymore. The nginx container is stuck in restarting state:
a4318065de88 nginx:1.13 "nginx -g 'daemon of…" 2 days ago Restarting (1) 54 seconds ago tutor_local_nginx_1

What are the logs from the nginx container? When in doubt, you can simply stop and start the platform:

tutor local stop
tutor local start

Ok my problem with nginx is solved by restarting the platform (thank you for the hint), but I still have the same problem with the url even after granting staff+superuser access to the existing user :
When I try to navigate to http://ecommerce.local.overhang.io/, when logged in I get redirected to Open edX dashboard and I get redirected to sign in page when the user is not logged in.

Please take a look at the updated instructions: https://github.com/overhangio/tutor-ecommerce/#creating-a-user
Start at “To re-use an existing LMS user…”.

2 Likes

Thank you very much. Problem solved.
Turns out I had forgot to replace 'USER@EMAIL.COM' with the admin user’s email address.