ciur / papermerge

Open Source Document Management System for Digital Archives (Scanned Documents)
https://papermerge.com
Apache License 2.0
2.41k stars 257 forks source link

User does not have a home folder #572

Closed thndrbck closed 5 months ago

thndrbck commented 6 months ago

In case you experience issues with docker image provided by linuxserver.io/papermerge, please open bug report in their repository.

Description After creating a new user, logging out the admin user, and trying to log in as the newly created user, get a screen with only this message: User does not have home folder Using the docker-compose file in the 3.0 documentation to run papermerge

Expected Expected a return to the log in screen so that I could log in as the newly created user

Actual No login screen. Just the above message

Info:

cezarasurdoiu commented 6 months ago

Hello! I've also encountered the same issue. As a workaround, I've tried to update the home_folder_id by performing a PATCH request on the specified endpoint (api/users/user_id), but without success. I've tried to change any other field (e.g. username, email) and it has worked, but for home_folder_id it still assigns null.

ciur commented 6 months ago

@thndrbck, @cezarasurdoiu thank you for reporting this issue. This is definitely a bug.

The bug is there because this line of code was not invoked upon user creation

Did you create new user via web UI ?

Until fix is available, here is the workaround:

While Papermerge instance is up and running , you need to enter into web app's docker container. For that:

$ docker ps

CONTAINER ID   IMAGE                       COMMAND                  CREATED        STATUS         PORTS                                     NAMES
8b74e4fac42f   pcore-web                   "/run.bash server"       14 hours ago   Up 6 minutes   0.0.0.0:11000->80/tcp, :::11000->80/tcp   pcore-web-1
4e59703425f8   pcore-worker                "/run.bash worker"       14 hours ago   Up 6 minutes   80/tcp                                    pcore-worker-1
d2d745d1428c   redis:6                     "docker-entrypoint.s…"   3 days ago     Up 6 minutes   6379/tcp                                  pcore-redis-1
e9bfa7258ac2   bitnami/postgresql:16.1.0   "/opt/bitnami/script…"   3 days ago     Up 6 minutes   5432/tcp                                  pcore-db-1

In example above, web app container is 8b74e4fac42f.

Then:

$ docker exec -it 8b74e4fac42f /bin/bash

While in container, activate app's virtual environment (without changing current folder, which by default is /core_app):

$ source ./venv/bin/activate

Then enter into Django's shell:

$ ./manage.py shell

In django shell run following commands (let's say user without home folder has username john):

1. from papermerge.core.models import User
2. user = User.objects.get(username='john')
3. user.create_special_folders()
4. user.save()

At this point your user should have both home folder and inbox folder; you can double check that with (while in Django's shell):

1. user.home_folder
2. user.inbox_folder

Both statements should return valid home/inbox folder with UUIDs

cezarasurdoiu commented 6 months ago

Hello, @ciur ! Yes, in my case, the new user was created via web UI. Thank you for the detailed workaround, it worked for me. Now, the login with a new user works as expected!

ciur commented 5 months ago

I cannot reproduce the problem locally, but intuitively I think where the problem may be.

This PR should fix the problem. The change is about creating users/inbox/home in one DB transaction.

The fix will be available in 3.0.1 release.

thndrbck commented 5 months ago

I'll test it again with version 3.01

On Sat, Jan 13, 2024, 2:17 AM Eugen Ciur @.***> wrote:

I cannot reproduce the problem locally, but intuitively I think where the problem may be.

This PR https://github.com/papermerge/papermerge-core/pull/301 should fix the problem. The change is about creating users/inbox/home in one DB transaction.

The fix will be available in 3.0.1 release.

— Reply to this email directly, view it on GitHub https://github.com/ciur/papermerge/issues/572#issuecomment-1890355198, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEADQQR3THWGP35JLN3XUGDYOIYKFAVCNFSM6AAAAABBNMT74KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJQGM2TKMJZHA . You are receiving this because you were mentioned.Message ID: @.***>