Skip to content

Commit

Permalink
fix: use helpers to create flow
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Aug 25, 2020
1 parent 3b2af53 commit aba8610
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions selfservice/flow/registration/flow.go
Expand Up @@ -75,19 +75,12 @@ type Flow struct {
}

func NewFlow(exp time.Duration, csrf string, r *http.Request, ft flow.Type) *Flow {
source := urlx.Copy(r.URL)
source.Host = r.Host

source.Scheme = "http"
if r.TLS != nil {
source.Scheme = "https"
}

now := time.Now().UTC()
return &Flow{
ID: x.NewUUID(),
ExpiresAt: time.Now().UTC().Add(exp),
IssuedAt: time.Now().UTC(),
RequestURL: source.String(),
ExpiresAt: now.Add(exp),
IssuedAt: now,
RequestURL: x.RequestURL(r).String(),
Methods: map[identity.CredentialsType]*FlowMethod{},
CSRFToken: csrf,
Type: ft,
Expand Down
2 changes: 1 addition & 1 deletion selfservice/flow/registration/flow_test.go
Expand Up @@ -57,7 +57,7 @@ func TestNewFlow(t *testing.T) {
r := registration.NewFlow(0, "csrf", &http.Request{
URL: urlx.ParseOrPanic("https://ory.sh/"),
Host: "ory.sh"}, flow.TypeBrowser)
assert.Equal(t, "http://ory.sh/", r.RequestURL)
assert.Equal(t, "https://ory.sh/", r.RequestURL)
})
}

Expand Down

0 comments on commit aba8610

Please sign in to comment.