Fixed user ID bug, added auth OK resonse
This commit is contained in:
parent
447aec742c
commit
865aab95a9
2
pkg.go
2
pkg.go
@ -112,7 +112,7 @@ func (service *Service) defaultAuthenticationHandler(req AuthenticationRequest,
|
||||
} // }}}
|
||||
func (service *Service) defaultAuthorizationHandler(sess *session.T, r *http.Request) (resp bool, err error) { // {{{
|
||||
resp = true
|
||||
service.logger.Error("webservice", "op", "authorization", "session", sess.UUID, "request", r, "authorized", resp)
|
||||
service.logger.Debug("webservice", "op", "authorization", "session", sess.UUID, "request", r.URL.String(), "authorized", resp)
|
||||
return
|
||||
} // }}}
|
||||
func (service *Service) defaultErrorHandler(err error, w http.ResponseWriter) { // {{{
|
||||
|
@ -20,6 +20,7 @@ type AuthenticationRequest struct {
|
||||
}
|
||||
|
||||
type AuthenticationResponse struct {
|
||||
OK bool
|
||||
Authenticated bool
|
||||
UserID int
|
||||
}
|
||||
@ -88,8 +89,8 @@ func (service *Service) sessionAuthenticate(w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
|
||||
// Authenticate against webservice user table if using a database.
|
||||
var userID int
|
||||
if service.Db != nil {
|
||||
var userID int
|
||||
authenticated, userID, err = service.Db.Authenticate(authRequest.Username, authRequest.Password)
|
||||
if err != nil {
|
||||
service.errorHandler(err, w)
|
||||
@ -113,7 +114,8 @@ func (service *Service) sessionAuthenticate(w http.ResponseWriter, r *http.Reque
|
||||
service.errorHandler(err, w)
|
||||
return
|
||||
}
|
||||
authResponse.UserID = sess.UserID
|
||||
authResponse.UserID = userID
|
||||
authResponse.OK = true
|
||||
|
||||
sess.Authenticated = authResponse.Authenticated
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user