From f15afa47807d176683f783c874c26f0c657cb625 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 5 Aug 2016 14:29:29 +0100 Subject: [PATCH] Use non-panicking type assertion --- src/github.com/matrix-org/go-neb/realms/github/github.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/go-neb/realms/github/github.go b/src/github.com/matrix-org/go-neb/realms/github/github.go index 6305b90..b928282 100644 --- a/src/github.com/matrix-org/go-neb/realms/github/github.go +++ b/src/github.com/matrix-org/go-neb/realms/github/github.go @@ -96,7 +96,11 @@ func (r *githubRealm) OnReceiveRedirect(w http.ResponseWriter, req *http.Request failWith(logger, w, 400, "Provided ?state= param is not recognised.", err) return } - ghSession := session.(*githubSession) + ghSession, ok := session.(*githubSession) + if !ok { + failWith(logger, w, 500, "Unexpected session found.", nil) + return + } logger.WithField("user_id", ghSession.UserID()).Print("Mapped redirect to user") // exchange code for access_token