Skip to content

Commit

Permalink
fix: OAuth clients limit links open in current tab
Browse files Browse the repository at this point in the history
  When the connected OAuth clients limit is reached on a Cozy, we
  display a blocking modal during the OAuth flow when trying to connect
  yet another client.
  In this situation we want the links displayed in the modal (i.e. to
  manage the connected clients or subscribe to another offer) to open in
  a new tab as this modal can be displayed in apps windows without any
  navigation means.

  However, when the modal is displayed when navigating in the Cozy in a
  browser because the limit has been exceeded, we don't have this
  limitation so the links should open in the same tab.
  • Loading branch information
taratatach committed Sep 18, 2023
1 parent 2b4553e commit fa80364
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
6 changes: 3 additions & 3 deletions assets/templates/oauth_clients_limit_exceeded.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ <h1 class="h4 h2-md mb-4 text-center">{{t "Too Many OAuth Clients Title" .Client
{{t "Too Many OAuth Clients Available Actions"}}
</p>
{{if .PremiumURL}}
<a href="{{.PremiumURL}}" target="_blank" class="btn btn-primary btn-md-lg w-100 mb-2">
<a href="{{.PremiumURL}}" {{with .OpenLinksInNewTab}}target="_blank"{{end}} class="btn btn-primary btn-md-lg w-100 mb-2">
{{t "Too Many OAuth Clients Offers Btn"}}
</a>
<a href="{{.ManageDevicesURL}}" target="_blank" class="btn btn-outline-info btn-md-lg w-100">
<a href="{{.ManageDevicesURL}}" {{with .OpenLinksInNewTab}}target="_blank"{{end}} class="btn btn-outline-info btn-md-lg w-100">
{{t "Too Many OAuth Clients Settings Btn"}}
</a>
{{else}}
<a href="{{.ManageDevicesURL}}" target="_blank" class="btn btn-primary btn-md-lg w-100">
<a href="{{.ManageDevicesURL}}" {{with .OpenLinksInNewTab}}target="_blank"{{end}} class="btn btn-primary btn-md-lg w-100">
{{t "Too Many OAuth Clients Settings Btn"}}
</a>
{{end}}
Expand Down
21 changes: 11 additions & 10 deletions web/auth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,17 @@ func (a *AuthorizeHTTPHandler) authorizeForm(c echo.Context) error {
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": manageDevicesURL,
"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": true,
"ManageDevicesURL": manageDevicesURL,
"PremiumURL": premiumURL,
"SettingsToken": settingsToken,
})
}
}
Expand Down
30 changes: 15 additions & 15 deletions web/statik/statik.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fa80364

Please sign in to comment.