Skip to content

Commit

Permalink
Update the logic to not call the GET Partials for non-supported prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya18101 committed Nov 28, 2024
1 parent 86cc188 commit 0a772a3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions internal/cli/universal_login_customize.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,16 @@ func (h *webSocketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}

func isSupportedPartial(givenPrompt management.PromptType) bool {
for _, prompt := range allowedPromptsWithPartials {
if givenPrompt == prompt {
return true
}
}

return false
}

func checkOriginFunc(r *http.Request) bool {
origin := r.Header["Origin"]
if len(origin) == 0 {
Expand Down Expand Up @@ -707,6 +717,12 @@ func fetchAllApplications(ctx context.Context, api *auth0.API) ([]*applicationDa
}

func fetchPartial(ctx context.Context, api *auth0.API, prompt *partialData) (*management.PromptScreenPartials, error) {
var filteredPartials = management.PromptScreenPartials{}

if !isSupportedPartial(management.PromptType(prompt.PromptName)) {
return &management.PromptScreenPartials{}, nil
}

partial, err := api.Prompt.GetPartials(ctx, management.PromptType(prompt.PromptName))
if err != nil {
return nil, err
Expand All @@ -716,8 +732,6 @@ func fetchPartial(ctx context.Context, api *auth0.API, prompt *partialData) (*ma
return &management.PromptScreenPartials{}, nil
}

filteredPartials := management.PromptScreenPartials{}

if screenPartials, ok := (*partial)[management.ScreenName(prompt.ScreenName)]; ok {
filteredPartials[management.ScreenName(prompt.ScreenName)] = screenPartials
}
Expand Down

0 comments on commit 0a772a3

Please sign in to comment.