volatiletech / authboss

The boss of http auth.
MIT License
3.79k stars 204 forks source link

Flash Message Still Exists When Changing Page. #340

Closed yusufmalikul closed 2 years ago

yusufmalikul commented 2 years ago

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: https://github.com/volatiletech/authboss/blob/e62387f74f1fd01cce883130882065b5bb701c8a/client_state.go#L373-L381

@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.