Exception while creating user with locode 8.3

Hello :slight_smile: ,
While trying the new release with identity integration, i found this error while creating a new user with locode, i have changed the provider to postgres and regenerated the ef core migration

This is a subset of the error i get on the console.

       Severity: ERROR
          SqlState: 23503
          MessageText: insert or update on table "AspNetUserRoles" violates foreign key constraint "FK_AspNetUserRoles_AspNetUsers_UserId"
          Detail: Key (UserId)=(797a4bfe-2f80-4d9e-8664-cf7ecbb0557e) is not present in table "AspNetUsers".
          SchemaName: public
          TableName: AspNetUserRoles
          ConstraintName: FK_AspNetUserRoles_AspNetUsers_UserId
          File: ri_triggers.c
          Line: 2465
          Routine: ri_ReportViolation
         --- End of inner exception stack trace ---

I made and example here to reproduce the issue here.

nukedbit/CreateUserPostgres (github.com)

Hi @nukedbit ,

I’ve pulled your repository, and wasn’t able to reproduce but maybe I am not following the same steps. I did the following.

  • Pulled your repository
  • Created a docker-compose.yml with the following configuration:
version: '3.8'

services:
  postgres:
    image: postgres:latest
    container_name: createuserpostgres
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: <your repository password>
      POSTGRES_DB: createuserpostgres
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:
  • Ran docker compose up on the root of the repository directory
  • Navigated to CreateUserPostgres AppHost directory
  • Ran npm run migrate
  • Ran the application with the https profile.
  • Logged in as admin@email.com with the default example password
  • Went to /admin-ui and Users
  • Clicked New User
  • Populated with:
    • User Name: Test
    • Email: test1@email.com
    • Phone: 12341234123
    • Password:
    • New Role: Employee

Clicked Create and it was successfully created:

If you run dotnet-ef migrations has-pending-model-changes do you have any pending changes?

Ok i think i have found where the issue is.
If you don’t specify the role, then i get an error that the password need at least one uppercase letter.
So now if i change the password to include one uppercase letter it works.
But if you specify the role you should get the password validation which is probably generating the other error

Thanks @nukedbit , that helped me reproduce the issue. I’ve applied a fix in this commit so that the correct error response is returned. This is now available in the pre-release feeds as 8.3.1.

1 Like