47 lines
1.4 KiB
Markdown
47 lines
1.4 KiB
Markdown
# Admin User Seeding Guide
|
|
|
|
This document explains how to manage the default admin user in the GAuth-Central application.
|
|
|
|
## Overview
|
|
|
|
Previously, the default admin user was created automatically every time the application started. This behavior has been changed to prevent accidental recreation or resetting of the admin user in production environments.
|
|
|
|
Now, the default admin user is **only** created when you explicitly run the seeding command.
|
|
|
|
## How to Seed the Admin User
|
|
|
|
To create the default admin user, run the application with the `seed-admin` argument:
|
|
|
|
```bash
|
|
go run main.go seed-admin
|
|
```
|
|
|
|
Or if you have built the binary:
|
|
|
|
```bash
|
|
./gauth-central seed-admin
|
|
```
|
|
|
|
### What this command does:
|
|
1. Checks if a user with email `admin@gauth.local` exists (including soft-deleted users).
|
|
2. **If not found:** Creates a new user with default credentials.
|
|
3. **If found but deleted:** Restores the user (sets `deleted_at` to NULL).
|
|
4. Ensures the user has the `admin` role assigned.
|
|
|
|
## Default Credentials
|
|
|
|
* **Email:** `admin@gauth.local`
|
|
* **Password:** `Admin@123`
|
|
|
|
> **⚠️ Security Warning:** Please change this password immediately after your first login!
|
|
|
|
## Running the Server Normally
|
|
|
|
To run the server without seeding the admin user (normal operation):
|
|
|
|
```bash
|
|
go run main.go
|
|
```
|
|
|
|
The application will connect to the database and run migrations, but it will **not** attempt to create or modify the default admin user.
|