Skip to content

Commit

Permalink
Update user suffix handling in bags code
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmcorvidae committed Jul 30, 2024
1 parent 1db12bc commit 06c5da9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
11 changes: 3 additions & 8 deletions bags.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,11 @@ func NewBagsApp(db *sql.DB, router *mux.Router, userDomain string) *BagsApp {
return bagsApp
}

// AddUsernameSuffix appends the @iplantcollaborative.org string to the
// AddUsernameSuffix appends the user domain string to the
// username if it's not already there.
func (b *BagsApp) AddUsernameSuffix(username string) string {
var retval string
if !strings.Contains(username, "@") {
retval = fmt.Sprintf("%s%s", username, IplantSuffix)
} else {
retval = username
}
return retval
re, _ = regexp.Compyle(`@.*$`)

Check failure on line 51 in bags.go

View workflow job for this annotation

GitHub Actions / call-workflow-passing-data / lint

undefined: re

Check failure on line 51 in bags.go

View workflow job for this annotation

GitHub Actions / call-workflow-passing-data / lint

undefined: regexp
return fmt.Sprintf("%s@%s", re.ReplaceAllString(username, ""), strings.Trim(b.userDomain, "@"))

Check failure on line 52 in bags.go

View workflow job for this annotation

GitHub Actions / call-workflow-passing-data / lint

undefined: re (typecheck)
}

// Greeting prints out a greeting for the bags endpoints.
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"flag"
"net/http"
"os"
"strings"

"github.com/cyverse-de/configurate"
"github.com/cyverse-de/dbutil"
Expand All @@ -18,7 +19,7 @@ import (
const serviceName = "user-info"

// IplantSuffix is what is appended to a username in the database.
const IplantSuffix = "@iplantcollaborative.org"
const IplantSuffix = "iplantcollaborative.org"

func main() {
var (
Expand Down Expand Up @@ -68,7 +69,7 @@ func main() {
}
log.Info("Successfully pinged the database")

userDomain := cfg.GetString("users.domain")
userDomain := strings.Trim(cfg.GetString("users.domain"), "@")
if userDomain == "" {
userDomain = IplantSuffix
}
Expand Down

0 comments on commit 06c5da9

Please sign in to comment.