Skip to content

Commit

Permalink
Merge pull request #1926 from chirino/fix-accept-link
Browse files Browse the repository at this point in the history
apiserver: fix accept link in the invitation email.
  • Loading branch information
chirino authored Feb 19, 2024
2 parents a08b568 + a86554d commit 39602e0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmd/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ func main() {
}

api.URL = command.String("url")
api.FrontendURL = command.StringSlice("origins")[0]
api.URLParsed, err = url.Parse(api.URL)
if err != nil {
log.Fatal(fmt.Errorf("invalid url: %w", err))
Expand Down
1 change: 1 addition & 0 deletions internal/handlers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type API struct {
SmtpServer email.SmtpServer
SmtpFrom string
caKeyPair CertificateKeyPair
FrontendURL string
}

func NewAPI(
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/invitation_emails.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (api *API) composeInvitationEmail(fromName string, to string, invitation *m
InvitationURL string
ExpiresIn string
}{
InvitationURL: fmt.Sprintf("%s#/invitations/%s/show", api.URL, invitation.ID),
InvitationURL: fmt.Sprintf("%s#/invitations/%s/show", api.FrontendURL, invitation.ID),
OrganizationName: orgName,
Subject: fmt.Sprintf("%s invited you to join %s", fromName, orgName),
From: fmt.Sprintf("%s <%s>", fromName, api.SmtpFrom),
Expand Down
6 changes: 3 additions & 3 deletions internal/handlers/invitation_emails_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ var expectedEmail string
func TestAPI_composeInvitationEmail(t *testing.T) {
require := require.New(t)
api := &API{
URL: "https://try.nexodus.io",
SmtpFrom: "[email protected]",
FrontendURL: "https://try.nexodus.io",
SmtpFrom: "[email protected]",
}
invite := &models.Invitation{
Base: models.Base{
Expand Down Expand Up @@ -49,7 +49,7 @@ func TestAPI_sendInvitationEmail(t *testing.T) {
t.SkipNow()
}
api := &API{
URL: "https://try.nexodus.io",
FrontendURL: "https://try.nexodus.io",
SmtpServer: email.SmtpServer{
HostPort: os.Getenv("NEXAPI_SMTP_HOST_PORT"),
User: os.Getenv("NEXAPI_SMTP_USER"),
Expand Down
2 changes: 1 addition & 1 deletion pkg/oidcagent/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (o *OidcAgent) LoginStart(c *gin.Context) {
c.AbortWithStatus(http.StatusInternalServerError)
return
}

c.SetSameSite(http.SameSiteLaxMode)
c.SetCookie("redirect", query.Redirect, int(time.Hour.Seconds()), "/", "", c.Request.URL.Scheme == "https", true)
c.SetCookie("failure", query.Failure, int(time.Hour.Seconds()), "/", "", c.Request.URL.Scheme == "https", true)
Expand Down

0 comments on commit 39602e0

Please sign in to comment.