archy/AUTH_LOGIN_FIX.md

128 lines
2.4 KiB
Markdown

# Auth Login Fix ✅
## Problem
When trying to login, got error: **"Unknown method: auth.login"**
## Root Cause
The `auth.login` method was defined in the code, but the `config` field was prefixed with `_` (marking it unused), which prevented the auth logic from accessing dev_mode settings.
## Fix Applied
**File:** `core/archipelago/src/api/rpc.rs`
Changed:
```rust
pub struct RpcHandler {
_config: Config, // ❌ Marked as unused
...
}
```
To:
```rust
pub struct RpcHandler {
config: Config, // ✅ Now accessible
...
}
```
This allows the auth handler to check if we're in dev mode and accept the default password.
## How Auth Works Now
### Dev Mode (default)
- **Password:** `password123`
- No setup required
- Works immediately for development
### Production Mode
- Requires user setup first
- Uses bcrypt password hashing
- Stored in data directory
## Rebuild & Test
```bash
cd /Users/dorian/Projects/archy
# 1. Rebuild backend
./clean-rebuild.sh
# 2. Start dev server
./scripts/dev-start.sh
```
Choose option 2 (Full stack)
### Login
**URL:** http://localhost:8100
**Password:** `password123`
Should log you in successfully! 🎉
## Available RPC Methods
The backend now supports:
**Auth:**
- `auth.login` - Login with password
- `auth.logout` - Logout
**Containers:**
- `container-install` - Install a container
- `container-start` - Start a container
- `container-stop` - Stop a container
- `container-remove` - Remove a container
- `container-list` - List all containers
- `container-status` - Get container status
- `container-logs` - Get container logs
- `container-health` - Get health status
**Packages:**
- `package.start` - Start docker-compose app
- `package.stop` - Stop docker-compose app
- `package.restart` - Restart docker-compose app
**Testing:**
- `echo` or `server.echo` - Echo back message
## Testing Auth
You can test the auth endpoint directly:
```bash
curl -X POST http://localhost:5959/rpc/v1 \
-H "Content-Type: application/json" \
-d '{
"method": "auth.login",
"params": {
"password": "password123"
}
}'
```
**Expected response:**
```json
{
"result": null,
"error": null
}
```
## Next Steps
Now that auth is working, you can:
1. **Navigate the UI** - All routes should work
2. **Install containers** - Try installing Bitcoin Core or Lightning
3. **Manage apps** - Start/stop containerized services
4. **View logs** - Monitor container output
---
**Auth is now fully functional!** 🔐