Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn developer to migrate & seed database if no user in the database #21856

Open
hikalkan opened this issue Jan 8, 2025 · 2 comments · May be fixed by #21906
Open

Warn developer to migrate & seed database if no user in the database #21856

hikalkan opened this issue Jan 8, 2025 · 2 comments · May be fixed by #21906

Comments

@hikalkan
Copy link
Member

hikalkan commented Jan 8, 2025

Sometimes developers forget to run DbMigrator to create and seed the database. Or somehow they delete the database later and use EF Core's Update-Database command to create the database again. As the result, they have the database tables, but the tables are empty. So, they can not login to the application.

In that situation, we can help developers to understand what is going on. My suggestion:

If we enter admin as user name, and the user was not found in the database, and if we are in development environment, throw a user-friendly exception like "Could not find the admin user. Please ensure that the database seed is executed. See https://abp.io/kb/0003 for possible solutions."

Please also complete that document: https://abp.io/docs/latest/kb/can-not-login-with-admin-user
I only added a list of topics that is covered in that document. You write all the possible reasons, their solutions, etc.

@ebicoglu
Copy link
Member

ebicoglu commented Jan 8, 2025

also it may not be a good solution to search for admin. users can intentionally delete admin user. my suggestion is checking any user in the AbpIoUsers table

@hikalkan
Copy link
Member Author

hikalkan commented Jan 8, 2025

@ebicoglu I said that only development time. And if developer writes "admin", then they probably know what they do. OK, if we want that check the whole table record count, then we should do it if admin user tries to login and it was not found. I don't want it takes time on every application startup or every application request, or on every login operation. Performance is critical and we don't want to decrease performance for something very rarely happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants