mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-18 18:04:32 +08:00
feat: add "forgot account" reset flow with wallet preservation
Add account reset functionality for users who forgot their login credentials. The reset clears authentication data while preserving wallet private keys and exchange configs, which are automatically adopted by the new account on re-registration to prevent fund loss. - Add POST /api/reset-account endpoint - Add "Forgot account?" button on login page (zh/en/id) - Orphan ai_models and exchanges are re-assigned to new user on register - Onboarding reuses existing claw402 wallet instead of generating new one Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -54,6 +54,24 @@ func (s *AIModelStore) initDefaultData() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindOrphanClaw402 finds a claw402 model whose user_id no longer exists in the users table.
|
||||
// Used to recover wallets after account reset.
|
||||
func (s *AIModelStore) FindOrphanClaw402() (*AIModel, error) {
|
||||
var model AIModel
|
||||
err := s.db.Where("provider = ? AND api_key != '' AND user_id NOT IN (SELECT id FROM users)", "claw402").
|
||||
First(&model).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &model, nil
|
||||
}
|
||||
|
||||
// AdoptModel re-assigns an existing model to a new user.
|
||||
func (s *AIModelStore) AdoptModel(modelID, newUserID string) error {
|
||||
return s.db.Model(&AIModel{}).Where("id = ?", modelID).
|
||||
Update("user_id", newUserID).Error
|
||||
}
|
||||
|
||||
// List retrieves user's AI model list
|
||||
func (s *AIModelStore) List(userID string) ([]*AIModel, error) {
|
||||
var models []*AIModel
|
||||
|
||||
Reference in New Issue
Block a user