Skip to content

Commit

Permalink
Rename survey-url to schema-url (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
berroar authored Apr 28, 2022
1 parent 998ab34 commit 91064b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions authentication/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func getSchemaClaims(LauncherSchema surveys.LauncherSchema) map[string]interface

schemaClaims := make(map[string]interface{})
if LauncherSchema.URL != "" {
schemaClaims["survey_url"] = LauncherSchema.URL
schemaClaims["schema_url"] = LauncherSchema.URL
}

return schemaClaims
Expand Down Expand Up @@ -346,8 +346,8 @@ func getStringOrDefault(key string, values map[string][]string, defaultValue str
}

// GenerateTokenFromDefaults coverts a set of DEFAULT values into a JWT
func GenerateTokenFromDefaults(surveyURL string, accountServiceURL string, accountServiceLogOutURL string, urlValues url.Values) (token string, error string) {
launcherSchema, validationError := launcherSchemaFromURL(surveyURL)
func GenerateTokenFromDefaults(schemaURL string, accountServiceURL string, accountServiceLogOutURL string, urlValues url.Values) (token string, error string) {
launcherSchema, validationError := launcherSchemaFromURL(schemaURL)
if validationError != "" {
return "", validationError
}
Expand Down Expand Up @@ -406,7 +406,7 @@ func GenerateTokenFromPost(postValues url.Values) (string, string) {
log.Println("POST received: ", postValues)

schemaName := TransformSchemaParamsToName(postValues)
schemaUrl := postValues.Get("survey_url")
schemaUrl := postValues.Get("schema_url")

launcherSchema := surveys.GetLauncherSchema(schemaName, schemaUrl)

Expand Down
8 changes: 4 additions & 4 deletions launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ func quickLauncherHandler(w http.ResponseWriter, r *http.Request) {
accountServiceURL := getAccountServiceURL(r)
AccountServiceLogOutURL := getAccountServiceURL(r)
urlValues := r.URL.Query()
surveyURL := urlValues.Get("url")
schemaURL := urlValues.Get("url")
defaultValues := authentication.GetDefaultValues()
log.Println("Quick launch request received", surveyURL)
log.Println("Quick launch request received", schemaURL)

urlValues.Add("ru_ref", defaultValues["ru_ref"])
collectionExerciseSid, _ := uuid.NewV4()
Expand All @@ -158,13 +158,13 @@ func quickLauncherHandler(w http.ResponseWriter, r *http.Request) {
urlValues.Add("language_code", defaultValues["language_code"])
urlValues.Add("response_expires_at", time.Now().AddDate(0, 0, 7).Format("2006-01-02T15:04:05+00:00"))

token, err := authentication.GenerateTokenFromDefaults(surveyURL, accountServiceURL, AccountServiceLogOutURL, urlValues)
token, err := authentication.GenerateTokenFromDefaults(schemaURL, accountServiceURL, AccountServiceLogOutURL, urlValues)
if err != "" {
http.Error(w, err, 400)
return
}

if surveyURL != "" {
if schemaURL != "" {
http.Redirect(w, r, hostURL+"/session?token="+token, 302)
} else {
http.Error(w, fmt.Sprintf("Not Found"), 404)
Expand Down
2 changes: 1 addition & 1 deletion templates/launch.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h1>Launch a survey</h1>
<div class="field-container">
<span>
<label for="schema-url">Schema URL</label>
<input id="schema-url" name="survey_url" type="text" class="qa-schema_url">
<input id="schema-url" name="schema_url" type="text" class="qa-schema_url">
</span>
</div>

Expand Down

0 comments on commit 91064b0

Please sign in to comment.