~netlandish/gobwebs

09b2799516bc89e18a920f1a59a8c70b3b1180f9 — Peter Sanchez 2 years ago ff4a64d
Letting the end application decide how to use 'next' when logging a user in
2 files changed, 5 insertions(+), 7 deletions(-)

M accounts/routes.go
M interfaces.go
M accounts/routes.go => accounts/routes.go +4 -6
@@ 62,7 62,7 @@ func (s *Service) Logout(c echo.Context) error {
func (s *Service) Login(c echo.Context) error {
	user := s.fetch.FromContext(c)
	if user.IsAuthenticated() {
		return c.Redirect(http.StatusMovedPermanently, s.fetch.RedirectAfterLogin(c))
		return c.Redirect(http.StatusMovedPermanently, s.fetch.RedirectAfterLogin(c, ""))
	}

	lt := s.fetch.LoginType()


@@ 135,9 135,7 @@ func (s *Service) LoginAuthPOST(c echo.Context) error {
		return err
	}

	if form.Next == "" {
		form.Next = s.fetch.RedirectAfterLogin(c)
	}
	form.Next = s.fetch.RedirectAfterLogin(c, form.Next)
	return c.Redirect(http.StatusMovedPermanently, form.Next)
}



@@ 250,7 248,7 @@ func (s *Service) LoginEmailConf(c echo.Context) error {
	if err := s.fetch.ProcessSuccessfulLogin(c, user); err != nil {
		return err
	}
	return c.Redirect(http.StatusMovedPermanently, s.fetch.RedirectAfterLogin(c))
	return c.Redirect(http.StatusMovedPermanently, s.fetch.RedirectAfterLogin(c, ""))
}

// ChangePassword changes the password for an authenticated user


@@ 305,7 303,7 @@ func (s *Service) ForgotPassword(c echo.Context) error {

	user := s.fetch.FromContext(c)
	if user.IsAuthenticated() {
		return c.Redirect(http.StatusMovedPermanently, s.fetch.RedirectAfterLogin(c))
		return c.Redirect(http.StatusMovedPermanently, s.fetch.RedirectAfterLogin(c, ""))
	}

	sent := c.QueryParam("sent")

M interfaces.go => interfaces.go +1 -1
@@ 60,7 60,7 @@ type UserFetch interface {
	ProcessSuccessfulEmailUpdate(c echo.Context) error
	ProcessSuccessfulEmailConfirmation(c echo.Context) error

	RedirectAfterLogin(c echo.Context) string
	RedirectAfterLogin(c echo.Context, next string) string
	RedirectAfterPasswordChange(c echo.Context) string
	RedirectAfterPasswordReset(c echo.Context) string
	RedirectAfterEmailUpdate(c echo.Context) string