Skip to content

Commit

Permalink
fix(Staging env): Fix staging env
Browse files Browse the repository at this point in the history
  • Loading branch information
Chadiii committed Aug 22, 2024
1 parent 6c5d674 commit ae39009
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
25 changes: 21 additions & 4 deletions utils/const.go
Original file line number Diff line number Diff line change
@@ -1,42 +1,59 @@
package utils

import (
"fmt"
"log"
"os"
)

func GetFeatureExperimentationHost() string {
if os.Getenv("FS_STAGING") == "true" {
if os.Getenv("ABT_STAGING") == "true" {
return "https://staging-api.flagship.io"
}

return "https://api.flagship.io"
}

func GetWebExperimentationHost() string {
if os.Getenv("FS_STAGING") == "true" {
if os.Getenv("ABT_STAGING") == "true" {
return "https://staging-api.abtasty.com/api"
}

return "https://api.abtasty.com/api"
}

func GetHostFeatureExperimentationAuth() string {
if os.Getenv("FS_STAGING") == "true" {
if os.Getenv("ABT_STAGING") == "true" {
return "https://staging-auth.flagship.io"
}

return "https://auth.flagship.io"
}

func GetHostWebExperimentationAuth() string {
if os.Getenv("FS_STAGING") == "true" {
if os.Getenv("ABT_STAGING") == "true" {
return "https://staging-api-auth.abtasty.com"
}

return "https://api-auth.abtasty.com"
}

func GetWebExperimentationBrowserAuth(clientId, clientSecret string) string {
if os.Getenv("ABT_STAGING") == "true" {
return fmt.Sprintf(`https://staging-auth.abtasty.com/authorize?client_id=%s&client_secret=%s&redirect_uri=http://localhost:8010/auth/callback`, clientId, clientSecret)
}

return fmt.Sprintf(`https://auth.abtasty.com/authorize?client_id=%s&client_secret=%s&redirect_uri=http://localhost:8010/auth/callback`, clientId, clientSecret)
}

func GetWebExperimentationBrowserAuthSuccess() string {
if os.Getenv("ABT_STAGING") == "true" {
return "https://staging-auth.abtasty.com/authorization-granted"
}

return "https://auth.abtasty.com/authorization-granted"
}

func DefaultGlobalCodeWorkingDir() string {
wdDir, err := os.Getwd()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions utils/http_request/common/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func handleCallback(w http.ResponseWriter, r *http.Request, codeChan chan<- stri

codeChan <- code

http.Redirect(w, r, "https://auth.abtasty.com/authorization-granted", http.StatusSeeOther)
http.Redirect(w, r, utils.GetWebExperimentationBrowserAuthSuccess(), http.StatusSeeOther)

go func() {
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -112,7 +112,7 @@ func InitiateBrowserAuth(username, clientID, clientSecret string) (models.TokenR
}

codeChan := make(chan string)
var url = fmt.Sprintf("https://auth.abtasty.com/authorize?client_id=%s&client_secret=%s&redirect_uri=http://localhost:8010/auth/callback", clientID, clientSecret)
var url = utils.GetWebExperimentationBrowserAuth(clientID, clientSecret)

if err := openLink(url); err != nil {
log.Fatalf("Error opening link: %s", err)
Expand Down

0 comments on commit ae39009

Please sign in to comment.