mirror of
https://github.com/miniflux/v2.git
synced 2025-10-05 19:31:01 +00:00
feat(login): redirect back to original page after logging in
This commit is contained in:
parent
5fa0709663
commit
5ffbf53eaf
4 changed files with 19 additions and 1 deletions
|
@ -6,6 +6,7 @@ package ui // import "miniflux.app/v2/internal/ui"
|
|||
import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"miniflux.app/v2/internal/config"
|
||||
"miniflux.app/v2/internal/http/cookie"
|
||||
|
@ -22,6 +23,8 @@ func (h *handler) checkLogin(w http.ResponseWriter, r *http.Request) {
|
|||
clientIP := request.ClientIP(r)
|
||||
sess := session.New(h.store, request.SessionID(r))
|
||||
view := view.New(h.tpl, r, sess)
|
||||
redirectURL := r.FormValue("redirect_url")
|
||||
view.Set("redirectURL", redirectURL)
|
||||
|
||||
if config.Opts.DisableLocalAuth() {
|
||||
slog.Warn("blocking local auth login attempt, local auth is disabled",
|
||||
|
@ -93,5 +96,12 @@ func (h *handler) checkLogin(w http.ResponseWriter, r *http.Request) {
|
|||
config.Opts.BasePath(),
|
||||
))
|
||||
|
||||
if redirectURL != "" {
|
||||
if parsedURL, err := url.Parse(redirectURL); err == nil && !parsedURL.IsAbs() {
|
||||
html.Redirect(w, r, redirectURL)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
html.Redirect(w, r, route.Path(h.router, user.DefaultHomePage))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue