Skip to content

Commit

Permalink
fix: Flagship's OAuth clients modal links opening (#4140)
Browse files Browse the repository at this point in the history
When the OAuth clients limit is exceeded, we redirect every HTML
request for an app to the dedicated modal page with links to subscribe
to a different offer or manage connected OAuth clients.

Although we want these links to open in the same tab on the Web, we
want them to open in a new tab when viewed from the flagship app.
  • Loading branch information
taratatach authored Sep 27, 2023
2 parents 6bd697a + f5a938b commit c0a2f50
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions web/settings/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ func (h *HTTPHandler) limitExceeded(c echo.Context) error {
count := len(clients)

if count > limit {
isFlagship, _ := strconv.ParseBool(c.QueryParam("isFlagship"))

connectedDevicesURL := inst.SubDomain(consts.SettingsSlug)
connectedDevicesURL.Fragment = "/connectedDevices"

var premiumURL string
if inst.HasPremiumLinksEnabled() {
isFlagship, _ := strconv.ParseBool(c.QueryParam("isFlagship"))
iapEnabled, _ := flags.M["flagship.iap.enabled"].(bool)
if !isFlagship || iapEnabled {
var err error
Expand All @@ -171,16 +172,17 @@ func (h *HTTPHandler) limitExceeded(c echo.Context) error {
sess, _ := middlewares.GetSession(c)
settingsToken := inst.BuildAppToken(consts.SettingsSlug, sess.ID())
return c.Render(http.StatusOK, "oauth_clients_limit_exceeded.html", echo.Map{
"Domain": inst.ContextualDomain(),
"ContextName": inst.ContextName,
"Locale": inst.Locale,
"Title": inst.TemplateTitle(),
"Favicon": middlewares.Favicon(inst),
"ClientsCount": strconv.Itoa(count),
"ClientsLimit": strconv.Itoa(limit),
"ManageDevicesURL": connectedDevicesURL.String(),
"PremiumURL": premiumURL,
"SettingsToken": settingsToken,
"Domain": inst.ContextualDomain(),
"ContextName": inst.ContextName,
"Locale": inst.Locale,
"Title": inst.TemplateTitle(),
"Favicon": middlewares.Favicon(inst),
"ClientsCount": strconv.Itoa(count),
"ClientsLimit": strconv.Itoa(limit),
"OpenLinksInNewTab": isFlagship,
"ManageDevicesURL": connectedDevicesURL.String(),
"PremiumURL": premiumURL,
"SettingsToken": settingsToken,
})
}
}
Expand Down

0 comments on commit c0a2f50

Please sign in to comment.