mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Login: Require user to not be signed in to get request password email (#35421)
This commit is contained in:
parent
395b942134
commit
7f882eea05
@ -23,6 +23,7 @@ var plog = log.New("api")
|
|||||||
func (hs *HTTPServer) registerRoutes() {
|
func (hs *HTTPServer) registerRoutes() {
|
||||||
reqNoAuth := middleware.NoAuth()
|
reqNoAuth := middleware.NoAuth()
|
||||||
reqSignedIn := middleware.ReqSignedIn
|
reqSignedIn := middleware.ReqSignedIn
|
||||||
|
reqNotSignedIn := middleware.ReqNotSignedIn
|
||||||
reqSignedInNoAnonymous := middleware.ReqSignedInNoAnonymous
|
reqSignedInNoAnonymous := middleware.ReqSignedInNoAnonymous
|
||||||
reqGrafanaAdmin := middleware.ReqGrafanaAdmin
|
reqGrafanaAdmin := middleware.ReqGrafanaAdmin
|
||||||
reqEditorRole := middleware.ReqEditorRole
|
reqEditorRole := middleware.ReqEditorRole
|
||||||
@ -112,7 +113,7 @@ func (hs *HTTPServer) registerRoutes() {
|
|||||||
r.Post("/api/user/invite/complete", bind(dtos.CompleteInviteForm{}), routing.Wrap(hs.CompleteInvite))
|
r.Post("/api/user/invite/complete", bind(dtos.CompleteInviteForm{}), routing.Wrap(hs.CompleteInvite))
|
||||||
|
|
||||||
// reset password
|
// reset password
|
||||||
r.Get("/user/password/send-reset-email", hs.Index)
|
r.Get("/user/password/send-reset-email", reqNotSignedIn, hs.Index)
|
||||||
r.Get("/user/password/reset", hs.Index)
|
r.Get("/user/password/reset", hs.Index)
|
||||||
|
|
||||||
r.Post("/api/user/password/send-reset-email", bind(dtos.SendResetPasswordEmailForm{}), routing.Wrap(SendResetPasswordEmail))
|
r.Post("/api/user/password/send-reset-email", bind(dtos.SendResetPasswordEmailForm{}), routing.Wrap(SendResetPasswordEmail))
|
||||||
|
@ -161,6 +161,12 @@ func SnapshotPublicModeOrSignedIn(cfg *setting.Cfg) macaron.Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ReqNotSignedIn(c *models.ReqContext) {
|
||||||
|
if c.IsSignedIn {
|
||||||
|
c.Redirect(setting.AppSubUrl + "/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NoAuth creates a middleware that doesn't require any authentication.
|
// NoAuth creates a middleware that doesn't require any authentication.
|
||||||
// If forceLogin param is set it will redirect the user to the login page.
|
// If forceLogin param is set it will redirect the user to the login page.
|
||||||
func NoAuth() macaron.Handler {
|
func NoAuth() macaron.Handler {
|
||||||
|
Loading…
Reference in New Issue
Block a user