@@ -88,7 +88,7 @@ func (h *TokenHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
8888 return
8989 }
9090
91- idToken , err := generateIDToken (h .issuerURL , clientID )
91+ idToken , err := h . generateIDToken (h .issuerURL , clientID )
9292 if err != nil {
9393 log .Printf ("Error generating ID token: %v" , err )
9494 http .Error (w , "Internal Server Error" , http .StatusInternalServerError )
@@ -139,11 +139,21 @@ func generateRefreshToken(clientID string) string {
139139}
140140
141141// Helper function to generate a mock ID token
142- func generateIDToken (issuerURL , clientID string ) (string , error ) {
142+ func ( h * TokenHandler ) generateIDToken (issuerURL , clientID string ) (string , error ) {
143143 // Generate a subject ID based on client ID
144144 sub := "user-" + clientID
145- // Generate a default email based on client ID
146- email := clientID + "@example.com"
147-
145+
146+ // Check if there's a configured email in the token config
147+ var email string
148+ tokenConfig := h .store .GetTokenConfig ()
149+ if tokenConfig != nil {
150+ if userInfoConfig , ok := tokenConfig ["user_info" ].(map [string ]interface {}); ok {
151+ if configuredEmail , ok := userInfoConfig ["email" ].(string ); ok {
152+ email = configuredEmail
153+ }
154+ }
155+ }
156+
157+ // If no email is configured, pass empty string (don't default to generated email)
148158 return jwt .GenerateIDToken (issuerURL , clientID , sub , email )
149159}
0 commit comments