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 1dbc812..30028a2 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 @@ -172,6 +172,11 @@ func (r *GithubRealm) OnReceiveRedirect(w http.ResponseWriter, req *http.Request } logger.WithField("user_id", ghSession.UserID()).Print("Mapped redirect to user") + if ghSession.AccessToken != "" && ghSession.Scopes != "" { + failWith(logger, w, 400, "You have already authenticated with Github", nil) + return + } + // exchange code for access_token res, err := http.PostForm("https://github.com/login/oauth/access_token", url.Values{"client_id": {r.ClientID}, "client_secret": {r.ClientSecret}, "code": {code}})