proxy: Return an error when autoprovision a user fails

Fixes: #6194
This commit is contained in:
Ralf Haferkamp
2023-05-24 17:17:15 +02:00
parent efc5e249e2
commit 3dc0fff1f4
2 changed files with 6 additions and 0 deletions
@@ -78,10 +78,14 @@ func (m accountResolver) ServeHTTP(w http.ResponseWriter, req *http.Request) {
user, err = m.userProvider.CreateUserFromClaims(req.Context(), claims)
if err != nil {
m.logger.Error().Err(err).Msg("Autoprovisioning user failed")
w.WriteHeader(http.StatusInternalServerError)
return
}
user, token, err = m.userProvider.GetUserByClaims(req.Context(), "userid", user.Id.OpaqueId)
if err != nil {
m.logger.Error().Err(err).Str("userid", user.Id.OpaqueId).Msg("Error getting token for autoprovisioned user")
w.WriteHeader(http.StatusUnauthorized)
return
}
}