openpim / server

Apache License 2.0
58 stars 24 forks source link

Problems logging in with admin/admin on fresh install of openpim/production:1.5 #20

Closed numbermess closed 1 year ago

numbermess commented 1 year ago

Hey there,

I am trying to evaluate using OpenPIM for a project at work, and I am running into an issue with logging in to the administrator interface. I have been able to run the production image mentioned in ./docker/docker-compose.yaml and try it out successfully, but I am having some issues getting it to work inside my environment. I am using a Postgres 15 database server.

The README says that I should be able to log in with admin/admin, but that isn't working for me. I am dropping/recreating the database for the application repeatedly to try and work through it. The script I am using to drop/recreate looks like:

drop database if exists lfm_openpim WITH (FORCE);
drop owned by lfm_openpim;
drop user if exists lfm_openpim;
create database lfm_openpim;
create user lfm_openpim with encrypted password 'lfm_openpim';
grant all privileges on database lfm_openpim to lfm_openpim;
grant all on schema public to lfm_openpim;
alter database lfm_openpim owner to lfm_openpim;
create extension if not exists ltree;

And I am importing the schema/data defined in init.sql similarly to how I see it used inside this repository:

PGPASSWORD=lfm_openpim psql -U lfm_openpim -d lfm_openpim -h postgres < data/openpim/init.sql

After running this, I can see that the Administrator account exists inside the database:

image

However, when I try logging in it just declines my request:

image

Is there a good way just to reset the administrator password from a database query? I tried rehashing admin with Bcrypt and updating the database row for the admin user, but that didn't work. I don't know what else to try here.

Thank you, Ben

numbermess commented 1 year ago

Update: I have this curse. It happens to me all the time, and it seems like it always must happen this way. I found what my problem was shortly after opening this issue.

I didn't see it right away, but there were several errors printed to the console when importing the init.sql file that said something like ERROR: must be member of postgres. I looked that up and found that the quickest solution for my scenario was just to grant the postgres role to my database user. So my drop & reload script now looks like:

drop database if exists lfm_openpim WITH (FORCE);
drop owned by lfm_openpim;
drop user if exists lfm_openpim;
create database lfm_openpim;
create user lfm_openpim with encrypted password 'lfm_openpim';
GRANT postgres to lfm_openpim; -- This is the new line which appears to resolve the import errors for a custom database user
grant all privileges on database lfm_openpim to lfm_openpim;
grant all on schema public to lfm_openpim;
alter database lfm_openpim owner to lfm_openpim;
create extension if not exists ltree;

Hopefully somebody else out there has my same curse and will see this before posting if they have the same issue.