forked from authgear/authgear-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle close settings page on success query param authgear#3813
- Loading branch information
Showing
10 changed files
with
953 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package webapp | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/authgear/authgear-server/pkg/auth/handler/webapp/viewmodels" | ||
"github.com/authgear/authgear-server/pkg/util/httproute" | ||
"github.com/authgear/authgear-server/pkg/util/template" | ||
) | ||
|
||
var TemplateWebSettingsCloseHTML = template.RegisterHTML( | ||
"web/settings_close.html", | ||
Components..., | ||
) | ||
|
||
func ConfigureSettingsCloseRoute(route httproute.Route) httproute.Route { | ||
return route. | ||
WithMethods("OPTIONS", "GET"). | ||
WithPathPattern("/settings/close") | ||
} | ||
|
||
type SettingsCloseHandler struct { | ||
ControllerFactory ControllerFactory | ||
BaseViewModel *viewmodels.BaseViewModeler | ||
Renderer Renderer | ||
} | ||
|
||
func (h *SettingsCloseHandler) GetData(r *http.Request, w http.ResponseWriter) (map[string]interface{}, error) { | ||
data := make(map[string]interface{}) | ||
baseViewModel := h.BaseViewModel.ViewModel(r, w) | ||
viewmodels.Embed(data, baseViewModel) | ||
return data, nil | ||
} | ||
|
||
func (h *SettingsCloseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
ctrl, err := h.ControllerFactory.New(r, w) | ||
if err != nil { | ||
http.Error(w, err.Error(), http.StatusBadRequest) | ||
return | ||
} | ||
defer ctrl.Serve() | ||
|
||
ctrl.Get(func() error { | ||
data, err := h.GetData(r, w) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
h.Renderer.RenderHTML(w, r, TemplateWebSettingsCloseHTML, data) | ||
return nil | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.