Wingysam / Christmas-Community

Christmas lists for families
GNU Affero General Public License v3.0
233 stars 41 forks source link

Cannot create admin account (/ redirects to /login) #134

Open gdeans opened 1 month ago

gdeans commented 1 month ago

I setup this docker on an RPi 4 with the default env file and it started fine. Browsed to the IP:port and it redirects to IP:port/login. There is no way to create an admin account per your instructions. Tried using guest and the password I set in the env file but that doesn't work either. Any ideas?

Wingysam commented 1 month ago

Try clearing your cookies for the site? That issue sounds familiar but I haven't experienced it in a year or two.

gdeans commented 1 month ago

Tried on 4 different devices with at least 2 browsers on each device. So I think cookies or any client side issues have been eliminated. I also tried opening a console on the container, but your docker image doesn't have bash so it's slow going. I'm not familiar with what you used to put this together so any help would be appreciated.

gdeans commented 1 month ago

I've now also tried portable browsers (K-Melon & Libre Wolf) in a different local account profile with no settings or plugins changed and get the same results. Attached is a copy of my compose and env files, but I don't think anything is wrong there. I just need to stop the redirect. Test_ChristmasCommunity.zip

Guiraud commented 1 month ago

Same issue here : cleaned the cookies.. cleaned the docker changed navigators.. any clue ?

Wingysam commented 1 month ago

So it's reproducible by trying to set the instance up with no volumes mounted on the latest docker image?

Guiraud commented 1 month ago

yes, I suppressed most of the .env variables and it worked. keeping only language, markdown and Smile. I'll narrow it down and come back to you :) must be a not RTFM behaviour on my part.

Guiraud commented 1 month ago

Ok, obviously it's all about DEFAULT_FAILURE_REDIRECT=/login. At the first login for the admin creation, this value should not be set.

But it would make sense to set this value after admin password creation.

I would recommend to set it afterward with the help of this stackoverflow redis answer

Although I think it is updated after first login. It should just be commented out in the Readme.md file.

gdeans commented 1 month ago

I commented the env file out in the docker compose yml and it worked. I added it back with only LANGUAGE defined in the env file and it worked again, but the CSS rendering was different for the setup page. Also the image doesn't seem to honor the PUID/PGID being set in the compose file and runs everything as root. I assume the container is running the web server as root or it's running it's setup routines as root and not changing the permissions to match the config. I'm deleting the secrets.txt and dbs folder before each test as well to make sure nothing passes from the previous test.

gdeans commented 1 month ago

OK, something is just not right here. I'm back to my original setup and it's working so there must be something outside the container or removing the container in portainer didn't wipe everything for some reason.

I did find out if I chown the data folder to the PUID/PGID it still works, so I think whatever process sets the structure up is a one-time thing run as root and it doesn't seem to matter afterwards, which is also odd.

My env file for reference:

## Core Settings
# Where to store databases, can be a CouchDB compatible server or directory.
#DB_PREFIX=dbs/
# Where to send someone if they need to log in
#DEFAULT_FAILURE_REDIRECT=/
# Port to listen on
PORT=80
# Expose the internal PouchDB with CouchDB API and Fauxton browser. Mostly used for debugging. Leave empty to disable.
DB_EXPOSE_PORT=
# Proxy to send item data requests to. Leave empty to disable.
PROXY_SERVER=
# Secret string to store session cookies with. Automatically generated if not provided.
SECRET=
# How long a user is logged in (milliseconds). Defaults to one week.
SESSION_MAX_AGE=604800000
# The name of the site in the <title> and navigation bar
SITE_TITLE=Test Family Christmas Community
# Used when shared to home screen
SHORT_TITLE=My Family Christmas
# The root path for forms, CSS, and a small amount of JS. Useful when proxying.
ROOT_PATH=/
# Where to trust the X-Forwarded-For header from. Defaults to "loopback". Useful for proxying to docker.
TRUST_PROXY=loopback
# Any theme from https://jenil.github.io/bulmaswatch
BULMASWATCH=journal
# Set to false to disable update notices
UPDATE_CHECK=true
# Set to false to disable the profile pictures feature
PFP=true
# Language of the interface, options listed in `languages` directory
LANGUAGE=en-US
# Password to enter guest mode,
# e.g. https://wishes.example.com?pw=ReplaceWithYourGuestPassword
# GUEST_PASSWORD=

## Wishlist Settings
# Set to true to not allow users to have their own lists. You may want this for a birthday or wedding.
SINGLE_LIST=false
# Set to false to allow viewing wishlists without logging in
LISTS_PUBLIC=false
# Defaults to true. Set to false for legacy cards view.
TABLE=true
# Convert Amazon links to Amazon Smile links. A percentage of the profit goes to a charity of buyer's choice. Defaults to true.
SMILE=true
# Allow Markdown in item notes. Does not work with TABLE=false. Defaults to false.
MARKDOWN=true

## Custom HTML Snippets
# These are inserted into specific locations in the relevant page
# HTML is not escaped. Don't put untrusted data here.
# CUSTOM_HTML_LOGIN=<p style="margin-top: 1em;">Some custom text for the Login page</p>
# CUSTOM_HTML_WISHLISTS=

# Custom CSS stylesheet
# If you wish to include a custom stylesheet you can add the filename in the variable here.
# Remember to add the stylesheet to the filesystem at `static/css/custom.css`. In docker, mount `/usr/src/app/src/static/css/custom.css`.
# CUSTOM_CSS=custom.css

My docker-compose.yml for reference:


name: test-christmas-community-project

# https://hub.docker.com/r/wingysam/christmas-community
# https://github.com/Wingysam/Christmas-Community

services:
  christmas-community:
    image: wingysam/christmas-community:latest
    container_name: test-christmas-community
    network_mode: bridge
    env_file: "/path/to/ChristmasCommunity/Test_ChristmasCommunity.env"
    environment:
      - TZ=America/New_York
      - PUID=1000
      - PGID=1000
      # Amazon Smile, set to 'false' to disable www.amazon.com links turning into smile.amazon.com
      #- SMILE=true
      # Table mode, set to 'false' to revert to box mode
      #- TABLE=true
      # Single list mode
      # (for weddings, birthdays, etc. only the admin account's list is accessible)
      # Set to 'true' to enable
      #- SINGLE_LIST=false
      # Some websites (like walmart) send headers that are larger than 8MB in length. If issues are encountered, set the node.js limit to a higher number than 8192
      #- NODE_OPTIONS=--max-http-header-size=32768
    volumes:
      - /path/to/ChristmasCommunity/data:/data
    ports:
      - 3280:80
    restart: unless-stopped
Wingysam commented 4 weeks ago

Do you have a way to make it reliably fail? Something is definitely wrong and I'd like to fix whatever caused that or at least make the app tell you what's wrong if it's a permissions issue or something.