immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
51.23k stars 2.71k forks source link

[BUG] First and Last name must be set on setup with OAuth #2735

Closed Pheggas closed 1 year ago

Pheggas commented 1 year ago

The bug

Hello. So i've set up immich on docker with additional custom proxy on top of immich's proxy and with OAuth service (Keycloak). I made a user in Keycloak but didn't specify the First and Last name. As soon as i hit Login with OAuth immich throws this error:

(user.firstName[0] + user.lastName[0]).toUpperCase is not a function - 500
TypeError: (user.firstName[0] + user.lastName[0]).toUpperCase is not a function
    at file:///usr/src/app/build/server/chunks/user-avatar-a532b375.js:98:72
    at Object.$$render (file:///usr/src/app/build/server/chunks/index3-d03b89d1.js:270:18)
    at file:///usr/src/app/build/server/chunks/user-page-layout-8adf66ef.js:325:79
    at Object.$$render (file:///usr/src/app/build/server/chunks/index3-d03b89d1.js:270:18)
    at file:///usr/src/app/build/server/chunks/user-page-layout-8adf66ef.js:799:90
    at Object.$$render (file:///usr/src/app/build/server/chunks/index3-d03b89d1.js:270:18)
    at file:///usr/src/app/build/server/chunks/_page.svelte-52ed759c.js:56:68
    at Object.$$render (file:///usr/src/app/build/server/chunks/index3-d03b89d1.js:270:18)
    at Object.default (file:///usr/src/app/build/server/index.js:89:97)
    at file:///usr/src/app/build/server/chunks/_layout.svelte-2cf582b6.js:579:32

With UI looking like: image

I used the Immich only for web for now so ignore Mobile App version.

The OS that Immich Server is running on

Ubuntu 22.04

Version of Immich Server

1.60.0

Version of Immich Mobile App

1.59.0

Platform with the issue

Your docker-compose.yml content

version: "3.8"

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: ["start-server.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - stack.env
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
    depends_on:
      - redis
      - database
      - typesense
    networks:

      - immich
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: ["start-microservices.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - stack.env
    depends_on:
      - redis
      - database
      - typesense
    networks:
      - immich
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /home/docker/docker_immich/model-cache:/cache
    env_file:
      - stack.env
    networks:
      - immich
    restart: always

  immich-web:
    container_name: immich_web
    image: ghcr.io/immich-app/immich-web:${IMMICH_VERSION:-release}
    env_file:
      - stack.env
    networks:
      - immich
    restart: always

  typesense:
    container_name: immich_typesense
    image: typesense/typesense:0.24.0
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_DATA_DIR=/data
    logging:
      driver: none
    volumes:
      - /home/docker/docker_immich/tsdata:/data
    networks:
      - immich
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2
    networks:
      - immich
    restart: always

  database:
    container_name: immich_postgres
    image: postgres:14
    env_file:
      - stack.env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      PG_DATA: /var/lib/postgresql/data
    networks:
      - immich
    volumes:
      - /home/docker/docker_immich/pgdata:/var/lib/postgresql/data
    restart: always

  immich-proxy:
    container_name: immich_proxy
    image: ghcr.io/immich-app/immich-proxy:${IMMICH_VERSION:-release}
    environment:
      # Make sure these values get passed through from the env file
      - IMMICH_SERVER_URL
      - IMMICH_WEB_URL
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.immich-local.rule=Host(`immich.local.dashrave.eu`)"
      - "traefik.http.routers.immich-local.entrypoints=web, websecure"
      - "traefik.http.routers.immich-local.tls=true"
      - "traefik.http.routers.immich-local.tls.certresolver=cloudflare"
      - "traefik.http.routers.immich-local.tls.domains[0].main=local.dashrave.eu"
      - "traefik.http.routers.immich-local.tls.domains[0].sans=*.local.dashrave.eu"
      - "traefik.docker.network=proxy"
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    networks:
      - proxy
      - immich
    ports:
      - 2283:8080
    depends_on:
      - immich-server
    restart: always

networks:
  immich:
  proxy:
    external: true

Your .env content

DB_HOSTNAME=immich_postgres
DB_USERNAME=redacted
DB_PASSWORD=redacted
DB_DATABASE_NAME=redacted
REDIS_HOSTNAME=immich_redis
UPLOAD_LOCATION=/mnt/redacted_path/immich
TYPESENSE_API_KEY=redacted
PUBLIC_LOGIN_PAGE_MESSAGE="It works!"
IMMICH_WEB_URL=http://immich-web:3000
IMMICH_SERVER_URL=http://immich-server:3001
IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003

Reproduction steps

1. Set up Immich 1.60.0 with custom proxy (Traefik) on top of it
2. Deploy Keycloak 21
3. Configure both Keycloak and Immich to work together
4. In Keycloak, add user to Immich realm with entering just username, email and password
5. Logout from Immich and click Login with OAuth
6. Enter the correct credentials that you created with user in Keycloak
7. See the error

Additional information

No response

Pheggas commented 1 year ago

Quick fix (before this issue gets fixed)

Add this to you docker-compose.yml to database container section

    stdin_open: true # docker run -i
    tty: true        # docker run -t

So i can access the command line.

  1. Access immich postgres (database) container CLI (i'm doing it by clicking "Exec Console" button in Portainer UI)
  2. Use the psql command (ex. psql -h [host] -d [database_name] -U [user]) and enter the password for your database user
  3. Do \c [database_name] (to connect to database)
  4. select * from users; # DON'T FORGET THE SEMICOLONS!
  5. update users set "<attribute>"='<value>', "<attribute>"='<value>' where "id"= '<uuid>'; (ex. update users set "firsName"='Josh', "lastName"='Steward' where "id"= '69aaa0ba-ac96-436b-b69c-31f4196ea8fc'; ) # DON'T FORGET THE SEMICOLONS! 5.1. The <attribute> and <value> is the attribute and value you want to set. <uuid> is ID you can read up from select * from users; command
  6. If it gives some output like "Update 1 line" or something like that, you can log in with new attributes.