Skip to content

Commit cef8fb2

Browse files
authored
Merge pull request #126 from getAlby/pass-app-name-as-state
Pass client app name as state parameter to oauth connection
2 parents 6b7be74 + dcba170 commit cef8fb2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

alby.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ func (svc *AlbyOAuthService) SendPaymentSync(ctx context.Context, senderPubkey,
407407
}
408408

409409
func (svc *AlbyOAuthService) AuthHandler(c echo.Context) error {
410+
appName := c.QueryParam("c") // c - for client
410411
// clear current session
411412
sess, _ := session.Get(CookieName, c)
412413
if sess.Values["user_id"] != nil {
@@ -419,7 +420,7 @@ func (svc *AlbyOAuthService) AuthHandler(c echo.Context) error {
419420
sess.Save(c.Request(), c.Response())
420421
}
421422

422-
url := svc.oauthConf.AuthCodeURL("")
423+
url := svc.oauthConf.AuthCodeURL(appName) // pass on the appName as state
423424
return c.Redirect(302, url)
424425
}
425426

echo_handlers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (svc *Service) AppsNewHandler(c echo.Context) error {
273273
sess.Options.Domain = svc.cfg.CookieDomain
274274
}
275275
sess.Save(c.Request(), c.Response())
276-
return c.Redirect(302, fmt.Sprintf("/%s/auth", strings.ToLower(svc.cfg.LNBackendType)))
276+
return c.Redirect(302, fmt.Sprintf("/%s/auth?c=%s", strings.ToLower(svc.cfg.LNBackendType), appName))
277277
}
278278

279279
//construction to return a map with all possible permissions

0 commit comments

Comments
 (0)