-
-
Notifications
You must be signed in to change notification settings - Fork 963
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: login and registration with code
style: format refactor: code cleanup and flow refinement feat: store code credential address type fix: login resend button and field errors fix: invalid code handling and error messages test(e2e): registration with code test: login and registration code fix: login and registration tests style: format test: registration with code error cases test: login with code error messages test: login with code test: login and registration code test: login errors fix: unit tests and verification flow fix: ui rendering on code group instead of default fix: sdk generation fix: sdk generation and tests chore: improve registration with code test
- Loading branch information
Showing
229 changed files
with
7,837 additions
and
1,185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
courier/template/courier/builtin/templates/login_code/valid/email.body.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Hi, | ||
|
||
please login to your account by entering the following code: | ||
|
||
{{ .LoginCode }} |
5 changes: 5 additions & 0 deletions
5
courier/template/courier/builtin/templates/login_code/valid/email.body.plaintext.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Hi, | ||
|
||
please login to your account by entering the following code: | ||
|
||
{{ .LoginCode }} |
1 change: 1 addition & 0 deletions
1
courier/template/courier/builtin/templates/login_code/valid/email.subject.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Login to your account |
5 changes: 5 additions & 0 deletions
5
courier/template/courier/builtin/templates/registration_code/valid/email.body.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Hi, | ||
|
||
please complete your account registration by entering the following code: | ||
|
||
{{ .RegistrationCode }} |
5 changes: 5 additions & 0 deletions
5
...er/template/courier/builtin/templates/registration_code/valid/email.body.plaintext.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Hi, | ||
|
||
please complete your account registration by entering the following code: | ||
|
||
{{ .RegistrationCode }} |
1 change: 1 addition & 0 deletions
1
courier/template/courier/builtin/templates/registration_code/valid/email.subject.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Complete your account registration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright © 2023 Ory Corp | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package email | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"os" | ||
"strings" | ||
|
||
"github.com/ory/kratos/courier/template" | ||
) | ||
|
||
type ( | ||
LoginCodeValid struct { | ||
deps template.Dependencies | ||
model *LoginCodeValidModel | ||
} | ||
LoginCodeValidModel struct { | ||
To string | ||
LoginCode string | ||
Identity map[string]interface{} | ||
} | ||
) | ||
|
||
func NewLoginCodeValid(d template.Dependencies, m *LoginCodeValidModel) *LoginCodeValid { | ||
return &LoginCodeValid{deps: d, model: m} | ||
} | ||
|
||
func (t *LoginCodeValid) EmailRecipient() (string, error) { | ||
return t.model.To, nil | ||
} | ||
|
||
func (t *LoginCodeValid) EmailSubject(ctx context.Context) (string, error) { | ||
subject, err := template.LoadText(ctx, t.deps, os.DirFS(t.deps.CourierConfig().CourierTemplatesRoot(ctx)), "login_code/valid/email.subject.gotmpl", "login_code/valid/email.subject*", t.model, t.deps.CourierConfig().CourierTemplatesLoginCodeValid(ctx).Subject) | ||
|
||
return strings.TrimSpace(subject), err | ||
} | ||
|
||
func (t *LoginCodeValid) EmailBody(ctx context.Context) (string, error) { | ||
return template.LoadHTML(ctx, t.deps, os.DirFS(t.deps.CourierConfig().CourierTemplatesRoot(ctx)), "login_code/valid/email.body.gotmpl", "login_code/valid/email.body*", t.model, t.deps.CourierConfig().CourierTemplatesLoginCodeValid(ctx).Body.HTML) | ||
} | ||
|
||
func (t *LoginCodeValid) EmailBodyPlaintext(ctx context.Context) (string, error) { | ||
return template.LoadText(ctx, t.deps, os.DirFS(t.deps.CourierConfig().CourierTemplatesRoot(ctx)), "login_code/valid/email.body.plaintext.gotmpl", "login_code/valid/email.body.plaintext*", t.model, t.deps.CourierConfig().CourierTemplatesLoginCodeValid(ctx).Body.PlainText) | ||
} | ||
|
||
func (t *LoginCodeValid) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(t.model) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright © 2023 Ory Corp | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package email_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/ory/kratos/courier" | ||
"github.com/ory/kratos/courier/template/email" | ||
"github.com/ory/kratos/courier/template/testhelpers" | ||
"github.com/ory/kratos/internal" | ||
) | ||
|
||
func TestLoginCodeValid(t *testing.T) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
t.Cleanup(cancel) | ||
|
||
t.Run("test=with courier templates directory", func(t *testing.T) { | ||
_, reg := internal.NewFastRegistryWithMocks(t) | ||
tpl := email.NewLoginCodeValid(reg, &email.LoginCodeValidModel{}) | ||
|
||
testhelpers.TestRendered(t, ctx, tpl) | ||
}) | ||
|
||
t.Run("test=with remote resources", func(t *testing.T) { | ||
testhelpers.TestRemoteTemplates(t, "../courier/builtin/templates/login_code/valid", courier.TypeLoginCodeValid) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright © 2023 Ory Corp | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package email | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"os" | ||
"strings" | ||
|
||
"github.com/ory/kratos/courier/template" | ||
) | ||
|
||
type ( | ||
RegistrationCodeValid struct { | ||
deps template.Dependencies | ||
model *RegistrationCodeValidModel | ||
} | ||
RegistrationCodeValidModel struct { | ||
To string | ||
Traits map[string]interface{} | ||
RegistrationCode string | ||
} | ||
) | ||
|
||
func NewRegistrationCodeValid(d template.Dependencies, m *RegistrationCodeValidModel) *RegistrationCodeValid { | ||
return &RegistrationCodeValid{deps: d, model: m} | ||
} | ||
|
||
func (t *RegistrationCodeValid) EmailRecipient() (string, error) { | ||
return t.model.To, nil | ||
} | ||
|
||
func (t *RegistrationCodeValid) EmailSubject(ctx context.Context) (string, error) { | ||
subject, err := template.LoadText(ctx, t.deps, os.DirFS(t.deps.CourierConfig().CourierTemplatesRoot(ctx)), "registration_code/valid/email.subject.gotmpl", "registration_code/valid/email.subject*", t.model, t.deps.CourierConfig().CourierTemplatesRegistrationCodeValid(ctx).Subject) | ||
|
||
return strings.TrimSpace(subject), err | ||
} | ||
|
||
func (t *RegistrationCodeValid) EmailBody(ctx context.Context) (string, error) { | ||
return template.LoadHTML(ctx, t.deps, os.DirFS(t.deps.CourierConfig().CourierTemplatesRoot(ctx)), "registration_code/valid/email.body.gotmpl", "registration_code/valid/email.body*", t.model, t.deps.CourierConfig().CourierTemplatesRegistrationCodeValid(ctx).Body.HTML) | ||
} | ||
|
||
func (t *RegistrationCodeValid) EmailBodyPlaintext(ctx context.Context) (string, error) { | ||
return template.LoadText(ctx, t.deps, os.DirFS(t.deps.CourierConfig().CourierTemplatesRoot(ctx)), "registration_code/valid/email.body.plaintext.gotmpl", "registration_code/valid/email.body.plaintext*", t.model, t.deps.CourierConfig().CourierTemplatesRegistrationCodeValid(ctx).Body.PlainText) | ||
} | ||
|
||
func (t *RegistrationCodeValid) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(t.model) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright © 2023 Ory Corp | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package email_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/ory/kratos/courier" | ||
"github.com/ory/kratos/courier/template/email" | ||
"github.com/ory/kratos/courier/template/testhelpers" | ||
"github.com/ory/kratos/internal" | ||
) | ||
|
||
func TestRegistrationCodeValid(t *testing.T) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
t.Cleanup(cancel) | ||
|
||
t.Run("test=with courier templates directory", func(t *testing.T) { | ||
_, reg := internal.NewFastRegistryWithMocks(t) | ||
tpl := email.NewRegistrationCodeValid(reg, &email.RegistrationCodeValidModel{}) | ||
|
||
testhelpers.TestRendered(t, ctx, tpl) | ||
}) | ||
|
||
t.Run("test=with remote resources", func(t *testing.T) { | ||
testhelpers.TestRemoteTemplates(t, "../courier/builtin/templates/registration_code/valid", courier.TypeRegistrationCodeValid) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.