Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flash Message Still Exists When Changing Page. #340

Closed
yusufmalikul opened this issue Jun 21, 2022 · 0 comments
Closed

Flash Message Still Exists When Changing Page. #340

yusufmalikul opened this issue Jun 21, 2022 · 0 comments

Comments

@yusufmalikul
Copy link

yusufmalikul commented Jun 21, 2022

Thank you for this great lib!

When doing some tests I reset an account and got this message.

An email has been sent to you with further instructions on how to reset your password.

Then I move to the Login page and that message above still appears.

How to set this flash message stuff to only show one time?

I use this to get flash messages:

func Home(w http.ResponseWriter, r *http.Request) {

	// ResponseWriter must be a ClientStateResponseWriter
	// ab is *authboss.Authboss
	csrw := ab.NewResponse(w)

	data := authboss.HTMLData{
		"flash_error":   authboss.FlashError(csrw, r),
		"flash_success": authboss.FlashSuccess(csrw, r),
	}
}

When I inspect the FlashSuccess function I see that the flash message flushed directly with DelSession:

authboss/client_state.go

Lines 373 to 381 in e62387f

func FlashSuccess(w http.ResponseWriter, r *http.Request) string {
str, ok := GetSession(r, FlashSuccessKey)
if !ok {
return ""
}
DelSession(w, FlashSuccessKey)
return str
}

@aarondl Could you help me with this flash message issue? Thank you.

edit:
After more debugging, I find out that my w is of type httptest.ResponseRecorder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant