fix: keep showing migration success page after creating migration file

After creating a node migration file the hub is halted and the Alby
OAuth token is intentionally removed, so visiting the homepage sent the
user through /start into the Alby OAuth flow. Track the halted state
in memory and redirect back to the migration success page instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland Bewick 2026-08-10 14:29:39 +07:00
parent ffee8cbcbe
commit 8b8fc45ee2
6 changed files with 21 additions and 0 deletions

View file

@ -50,6 +50,9 @@ type api struct {
startupError error
startupErrorTime time.Time
eventPublisher events.EventPublisher
// set after a migration file is created; the hub is halted at that point
// and the frontend should keep showing the migration success page
nodeMigrationFileCreated bool
}
func NewAPI(svc service.Service, gormDB *gorm.DB, config config.Config, keys keys.Keys, albySvc alby.AlbyService, albyOAuthSvc alby.AlbyOAuthService, eventPublisher events.EventPublisher) *api {
@ -1510,6 +1513,7 @@ func (api *api) GetInfo(ctx context.Context) (*InfoResponse, error) {
}
lnClient := api.svc.GetLNClient()
info.Running = lnClient != nil
info.NodeMigrationFileCreated = api.nodeMigrationFileCreated
info.BackendType = backendType
info.AlbyAuthUrl = api.albyOAuthSvc.GetAuthUrl()
info.OAuthRedirect = !api.cfg.GetEnv().IsDefaultClientId()

View file

@ -197,6 +197,8 @@ func (api *api) CreateBackup(unlockPassword string, w io.Writer) error {
logger.Logger.Info("Successfully created backup to migrate Alby Hub to another device")
api.nodeMigrationFileCreated = true
return nil
}

View file

@ -338,6 +338,7 @@ type InfoResponse struct {
JitChannelsEnabled bool `json:"jitChannelsEnabled"`
HideUpdateBanner bool `json:"hideUpdateBanner"`
SupportsBolt12 bool `json:"supportsBolt12"`
NodeMigrationFileCreated bool `json:"nodeMigrationFileCreated"`
}
type UpdateSettingsRequest struct {

View file

@ -14,6 +14,13 @@ export function HomeRedirect() {
return;
}
if (info.nodeMigrationFileCreated) {
// the hub is halted after creating a migration file and should not be
// used anymore, so keep showing the migration success instructions
navigate("/create-node-migration-file-success", { replace: true });
return;
}
const setupReturnTo = window.localStorage.getItem(
localStorageKeys.setupReturnTo
);

View file

@ -9,6 +9,12 @@ export function StartRedirect({ children }: React.PropsWithChildren) {
const navigate = useNavigate();
React.useEffect(() => {
if (info?.nodeMigrationFileCreated) {
// the hub is halted after creating a migration file and should not be
// used anymore, so keep showing the migration success instructions
navigate("/create-node-migration-file-success", { replace: true });
return;
}
if (!info || (info.setupCompleted && !info.running)) {
if (info && !info.albyAccountConnected && info.albyUserIdentifier) {
navigate("/alby/auth");

View file

@ -187,6 +187,7 @@ export interface InfoResponse {
jitChannelsEnabled: boolean;
hideUpdateBanner: boolean;
supportsBolt12: boolean;
nodeMigrationFileCreated: boolean;
}
export type BitcoinDisplayFormat = "sats" | "bip177";