Skip to content

Commit

Permalink
fixed server error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
LyricTian committed Aug 11, 2016
1 parent 1f76fdf commit 6a41b99
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,16 @@ func (s *Server) GetAuthorizeData(rt oauth2.ResponseType, ti oauth2.TokenInfo) (
}

// HandleAuthorizeRequest the authorization request handling
func (s *Server) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request) (uerr error) {
req, err := s.ValidationAuthorizeRequest(r)
if err != nil {
uerr = s.resRedirectError(w, req, err)
func (s *Server) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request) (err error) {
req, verr := s.ValidationAuthorizeRequest(r)
if verr != nil {
err = s.resRedirectError(w, req, verr)
return
}
// user authorization
userID, err := s.UserAuthorizationHandler(w, r)
if err != nil {
uerr = s.resRedirectError(w, req, err)
userID, verr := s.UserAuthorizationHandler(w, r)
if verr != nil {
err = s.resRedirectError(w, req, verr)
return
} else if userID == "" {
return
Expand All @@ -254,12 +254,12 @@ func (s *Server) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request)
req.AccessTokenExp = exp
}
}
ti, err := s.GetAuthorizeToken(req)
if err != nil {
uerr = s.resRedirectError(w, req, err)
ti, verr := s.GetAuthorizeToken(req)
if verr != nil {
err = s.resRedirectError(w, req, verr)
return
}
uerr = s.resRedirect(w, req, s.GetAuthorizeData(req.ResponseType, ti))
err = s.resRedirect(w, req, s.GetAuthorizeData(req.ResponseType, ti))
return
}

Expand Down Expand Up @@ -430,15 +430,15 @@ func (s *Server) GetTokenData(ti oauth2.TokenInfo) (data map[string]interface{})
}

// HandleTokenRequest token request handling
func (s *Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request) (uerr error) {
gt, tgr, err := s.ValidationTokenRequest(r)
if err != nil {
err = s.resTokenError(w, err)
func (s *Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request) (err error) {
gt, tgr, verr := s.ValidationTokenRequest(r)
if verr != nil {
err = s.resTokenError(w, verr)
return
}
ti, err := s.GetAccessToken(gt, tgr)
if err != nil {
err = s.resTokenError(w, err)
ti, verr := s.GetAccessToken(gt, tgr)
if verr != nil {
err = s.resTokenError(w, verr)
return
}
err = s.resToken(w, s.GetTokenData(ti))
Expand Down

0 comments on commit 6a41b99

Please sign in to comment.