MDeLuise / plant-it

🪴 Self-hosted, open source gardening companion app
https://plant-it.org
GNU General Public License v3.0
455 stars 17 forks source link

Cannot login after creating user #143

Open krillin666 opened 2 months ago

krillin666 commented 2 months ago

Avoid duplicated bug reports

Description

After creating a user in the platform it automatically logins as this user. However, if attempting to login using these credentials in another device, browser, or in the same browser (after whipping data) it gives a bad credentials error.

I've tried creating multiple users and this error happens always. In the backend logs I see something like Temporary password for user MyUsername not found. I don't have access to the logs now, but I can post them later.

Thank you so much for your work!

Expected behaviour

No response

Steps to reproduce

No response

Local environment

Running on a RPI 4 with debian bookworm 64bits. Latest docker version with reverse proxy using nginx. I'll post my config later!

docker-compose:

version: "3"
name: plant-it
services:
  backend:
    image: msdeluise/plant-it-backend:latest
    env_file: backend.env
    depends_on:
      - db
      - cache
    restart: unless-stopped
    volumes:
      - "./upload-dir:/upload-dir"
      - "./certs:/certificates"
    ports:
      - "8089:8080"
  db:
    image: mysql:8.0
    restart: always
    env_file: backend.env
    volumes:
      - "./db:/var/lib/mysql"
  cache:
    image: redis:7.2.1
    restart: always
  frontend:
    image: msdeluise/plant-it-frontend:latest
    env_file: frontend.env
    links:
      - backend
    ports:
      - "3009:3000"
    volumes:
      - "./certs:/certificates"
volumes:
  certs:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: ./certificates

Backend:

#
# DB
#
MYSQL_HOST=db
MYSQL_PORT=3306
MYSQL_USERNAME=root
MYSQL_PSW=myroot
MYSQL_ROOT_PASSWORD=myroot
MYSQL_DATABASE=bootdb

#
# JWT
#
JWT_SECRET=llllcharacterscomplicatedsecret
JWT_EXP=1

#
# Server config
#
USERS_LIMIT=2
UPLOAD_DIR=/upload-dir
API_PORT=8080
TREFLE_KEY=mykey
ALLOWED_ORIGINS=https://plantit.mysite.com
#
# Cache
#
CACHE_TTL=86400
CACHE_HOST=cache
CACHE_PORT=6379

#
# SSL
#
SSL_ENABLED=false
CERTIFICATE_PATH=/certificates/

LOG_LEVEL=DEBUG

Frontend:

PORT=3000
API_URL=https://plantitdb.mysite.com/api
WAIT_TIMEOUT=50000
PAGE_SIZE=25
BROWSER=none
SSL_ENABLED=true
CERTIFICATE_PATH=/certificates/

Logs:

afe use of the session): org.hibernate.AssertionFailure: force initializing collection loading
2024-04-15T13:45:34.247Z ERROR 14 --- [nio-8080-exec-6] c.g.m.p.n.p.TemporaryPasswordService     : Temporary password not found for user Planti
2024-04-15T13:45:41.854Z ERROR 14 --- [nio-8080-exec-3] c.g.m.p.n.p.TemporaryPasswordService     : Temporary password not found for user Planti
2024-04-15T13:45:45.899Z ERROR 14 --- [nio-8080-exec-1] c.g.m.p.n.p.TemporaryPasswordService     : Temporary password not found for user Planti
2024-04-15T22:24:54.612Z DEBUG 14 --- [io-8080-exec-10] c.g.m.p.systeminfo.SystemVersionService  : retrieve the system version info from GitHub.
2024-04-15T22:24:54.830Z DEBUG 14 --- [nio-8080-exec-5] c.g.mdeluise.plantit.plant.PlantService  : Search for DB saved plants
2024-04-15T22:24:54.894Z DEBUG 14 --- [nio-8080-exec-3] c.g.m.p.p.PlantInfoExtractorFacade       : Search all botanical info
2024-04-15T22:24:54.895Z DEBUG 14 --- [nio-8080-exec-3] c.g.m.p.b.BotanicalInfoService           : Search for DB saved botanical info (max size 5)
2024-04-15T22:24:54.919Z DEBUG 14 --- [nio-8080-exec-3] c.g.m.p.p.trafle.TrefleRequestMaker      : Fetching all info from Trefle
2024-04-15T22:25:14.543Z ERROR 14 --- [nio-8080-exec-5] c.g.m.p.n.p.TemporaryPasswordService     : Temporary password not found for user Plantae
2024-04-16T07:30:00.003Z  INFO 14 --- [   scheduling-1] c.g.m.p.reminder.ReminderDispatcher      : Starting reminder dispatching...

Additional info

No response

zahedhelmand commented 2 months ago

Maybe my problem is related. Plant-It is running and i can connect to plantit.MYDOMAIN.com/auth Now i can login or create an user (first start). When i want to create my user, it shows: "ERROR" with no information in the logs. image

I am using docker with traefik config as here: https://github.com/MDeLuise/plant-it/issues/144

MDeLuise commented 2 months ago

Hi! Could you please share the docker-compose log?

krillin666 commented 2 months ago

Hi! Could you please share the docker-compose log?

Just edited my post with all my configs. Thank you!

ishcabittle commented 2 months ago

Maybe my problem is related. Plant-It is running and i can connect to plantit.MYDOMAIN.com/auth Now i can login or create an user (first start). When i want to create my user, it shows: "ERROR" with no information in the logs. image

I am using docker with traefik config as here: #144

I'm having this issue as well. New install, http host with an Nginx Proxy Manager https connection.

ishcabittle commented 2 months ago

@krillin666 - I have narrowed our issue down to using an external reverse proxy. Changing my API_URL from https://my.domain.com/api to http://192.168.1.50:8080/api resolved the error and I was able to create a user and log in. I had hoped that after I created the user I could switch back to my FQDN but no dice.

krillin666 commented 2 months ago

@krillin666 - I have narrowed our issue down to using an external reverse proxy. Changing my API_URL from https://my.domain.com/api to http://192.168.1.50:8080/api resolved the error and I was able to create a user and log in. I had hoped that after I created the user I could switch back to my FQDN but no dice.

Thanks for sharing your findings @ishcabittle ! @MDeLuise congratulations with the new release ! Do you know if we now set the backend to a reverse proxy address these problems will still be present ? I can test it later today, @ishcabittle did you tried it already ?

MDeLuise commented 2 months ago

Hi there!

@MDeLuise congratulations with the new release ! Do you know if we now set the backend to a reverse proxy address these problems will still be present ?

Thank you for the congratulations! While it's not entirely clear why these issues are occurring, I recommend giving the new release a try. With the frontend of the app being fully rewritten (transitioning from TypeScript to Flutter), different frameworks may handle HTTP requests differently, which could potentially resolve the problems you've encountered.

Please keep in mind that there have been some changes to the deployment process in this release, as outlined in the release notes.

Additionally, it's worth noting that the Traefik deployment in the documentation may need some updates.

Let me know if the 0.5.0 version of the project addresses these issues for you. If not, we'll dive deeper into finding a solution

ishcabittle commented 2 months ago

@krillin666 - I have narrowed our issue down to using an external reverse proxy. Changing my API_URL from https://my.domain.com/api to http://192.168.1.50:8080/api resolved the error and I was able to create a user and log in. I had hoped that after I created the user I could switch back to my FQDN but no dice.

Thanks for sharing your findings @ishcabittle ! @MDeLuise congratulations with the new release ! Do you know if we now set the backend to a reverse proxy address these problems will still be present ? I can test it later today, @ishcabittle did you tried it already ?

I did upgrade to the new release, unfortunately I am still receiving the network error. Because it works perfectly when pointing to the internal IP address, I'm fine with it for now.

krillin666 commented 2 months ago

@krillin666 - I have narrowed our issue down to using an external reverse proxy. Changing my API_URL from my.domain.com/api to http://192.168.1.50:8080/api resolved the error and I was able to create a user and log in. I had hoped that after I created the user I could switch back to my FQDN but no dice.

Thanks for sharing your findings @ishcabittle ! @MDeLuise congratulations with the new release ! Do you know if we now set the backend to a reverse proxy address these problems will still be present ? I can test it later today, @ishcabittle did you tried it already ?

I did upgrade to the new release, unfortunately I am still receiving the network error. Because it works perfectly when pointing to the internal IP address, I'm fine with it for now.

I'm trying to deploy the new version from start, but I'm getting cannot connect to the server error . And when I try to access the db it shows Bad Request This combination of host and port requires TLS.

MDeLuise commented 1 month ago

Hi everyone, I wanted to share an update regarding Traefik. I've successfully set up a functional local environment, which might be useful for those of you using Traefik (or are using other proxy maybe). I'll be sure to incorporate this into the official documentation to highlight its utility.

Here's the configuration for the working deployment:

version: '3'

services:
  reverse-proxy:
    image: traefik:v3.0
    command: --api.insecure=true --providers.docker
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  server:
    image: msdeluise/plant-it-server:0.5.1-beta
    env_file: server.env
    depends_on:
      - db
      - cache
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.app.rule=Host(`plant-it.docker.localhost`)"
      - "traefik.http.routers.app.service=server"
      - "traefik.http.routers.app.entrypoints=http"
      - "traefik.http.services.server.loadbalancer.server.port=3000"

      - "traefik.http.routers.api.rule=Host(`plant-it-api.docker.localhost`)"
      - "traefik.http.routers.api.service=server-api"
      - "traefik.http.routers.api.entrypoints=http"
      - "traefik.http.services.server-api.loadbalancer.server.port=8080"

  db:
    image: mysql:8.0
    restart: always
    env_file: server.env
    volumes:
      - "./db:/var/lib/mysql"
    labels:
      - "traefik.enable=false"

  cache:
    image: redis:7.2.1
    restart: always
    labels:
      - "traefik.enable=false"

In this example you can visit http://plant-it.docker.localhost for accessing the app, and http://plant-it-api.docker.localhost/api/swagger-ui/index.html for accessing the Swagger UI. Use http://plant-it-api.docker.localhost as server URL when request in the app setup.