saml
saml copied to clipboard
Handle error before handling session in Middleware.RequireAccount
m.RequireAccount checks if session is nil and only handles error when it is. When using custom implementations of SessionProvider, it is possible that the provider returns a non-nil Session when an error occurred. This pr handles the error and checks for nil Session before passing the session to the context. Also, checking for ErrNoSession is done with the standard library's errors.Is (added to the standard library in Go 1.13). This way, custom implementations of the SessionProvider interface can wrap the error if they need to provide additional context down the line.