Skip to content

Commit

Permalink
fix: do not allow duplicate getalby.com apps (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz authored Jul 29, 2024
1 parent 4a41462 commit 4d50a98
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion alby/alby_oauth_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ func (svc *albyOAuthService) GetAuthUrl() string {
}

func (svc *albyOAuthService) LinkAccount(ctx context.Context, lnClient lnclient.LNClient, budget uint64, renewal string) error {
appName := "getalby.com"

// delete any existing getalby.com connections to ensure user only sees the new one
svc.db.Where("name = ?", appName).Delete(&db.App{})

connectionPubkey, err := svc.createAlbyAccountNWCNode(ctx)
if err != nil {
logger.Logger.WithError(err).Error("Failed to create alby account nwc node")
Expand All @@ -413,7 +418,7 @@ func (svc *albyOAuthService) LinkAccount(ctx context.Context, lnClient lnclient.
}

app, _, err := db.NewDBService(svc.db, svc.eventPublisher).CreateApp(
"getalby.com",
appName,
connectionPubkey,
budget,
renewal,
Expand Down

0 comments on commit 4d50a98

Please sign in to comment.