(w http.ResponseWriter, r *http.Request)
| 3057 | h.microsoftFlowMu.Lock() |
| 3058 | if h.microsoftSessionCanceledLocked(req.SessionID, time.Now()) { |
| 3059 | h.microsoftFlowMu.Unlock() |
| 3060 | clearMicrosoftAccountCredential(&account) |
| 3061 | h.writeMicrosoftSSOCanceled(w) |
| 3062 | return |
| 3063 | } |
| 3064 | if discoveryErr != nil { |
| 3065 | h.microsoftFlowMu.Unlock() |
| 3066 | clearMicrosoftAccountCredential(&account) |
| 3067 | w.WriteHeader(http.StatusGatewayTimeout) |
| 3068 | json.NewEncoder(w).Encode(map[string]string{"error": "Microsoft profile discovery was canceled or timed out"}) |
| 3069 | return |
| 3070 | } |
| 3071 | if len(profiles) > 1 { |
| 3072 | selectionID, expiredSelections, err := h.storeMicrosoftProfileSelection(req.SessionID, account, profiles) |
| 3073 | h.microsoftFlowMu.Unlock() |
| 3074 | discardDetachedMicrosoftProfileSelections(expiredSelections) |
| 3075 | if err != nil { |
| 3076 | clearMicrosoftAccountCredential(&account) |
| 3077 | w.WriteHeader(http.StatusServiceUnavailable) |
| 3078 | json.NewEncoder(w).Encode(map[string]string{"error": err.Error()}) |
| 3079 | return |
| 3080 | } |
| 3081 | json.NewEncoder(w).Encode(map[string]interface{}{ |
| 3082 | "success": true, |
| 3083 | "stage": "profile", |
| 3084 | "requiresProfileSelection": true, |
| 3085 | "selectionId": selectionID, |
| 3086 | "profiles": profiles, |
| 3087 | }) |
| 3088 | return |
| 3089 | } |
| 3090 | if len(profiles) == 1 { |
| 3091 | account.ProfileArn = profiles[0].ARN |
| 3092 | } |
| 3093 | if err := config.AddAccount(account); err != nil { |
no test coverage detected