Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
129 lines
3.9 KiB
Go
129 lines
3.9 KiB
Go
// Copyright © 2023 Ory Corp
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package text
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/ory/x/clock"
|
|
)
|
|
|
|
func NewErrorValidationRecoveryFlowExpired(c clock.Clock, expiredAt time.Time) *Message {
|
|
return &Message{
|
|
ID: ErrorValidationRecoveryFlowExpired,
|
|
Text: fmt.Sprintf("The recovery flow expired %.2f minutes ago, please try again.", c.Now().Sub(expiredAt).Minutes()),
|
|
Type: Error,
|
|
Context: context(map[string]any{
|
|
"expired_at": expiredAt,
|
|
"expired_at_unix": expiredAt.Unix(),
|
|
}),
|
|
}
|
|
}
|
|
|
|
func NewRecoverySuccessful(c clock.Clock, privilegedSessionExpiresAt time.Time) *Message {
|
|
hasLeft := privilegedSessionExpiresAt.Sub(c.Now())
|
|
return &Message{
|
|
ID: InfoSelfServiceRecoverySuccessful,
|
|
Type: Success,
|
|
Text: fmt.Sprintf("You successfully recovered your account. Please change your password or set up an alternative login method (e.g. social sign in) within the next %.2f minutes.", hasLeft.Minutes()),
|
|
Context: context(map[string]any{
|
|
"privilegedSessionExpiresAt": privilegedSessionExpiresAt,
|
|
"privileged_session_expires_at": privilegedSessionExpiresAt,
|
|
"privileged_session_expires_at_unix": privilegedSessionExpiresAt.Unix(),
|
|
}),
|
|
}
|
|
}
|
|
|
|
func NewRecoveryEmailSent() *Message {
|
|
return &Message{
|
|
ID: InfoSelfServiceRecoveryEmailSent,
|
|
Type: Info,
|
|
Text: "An email containing a recovery link has been sent to the email address you provided. If you have not received an email, check the spelling of the address and make sure to use the address you registered with.",
|
|
}
|
|
}
|
|
|
|
func NewRecoveryEmailWithCodeSent() *Message {
|
|
return &Message{
|
|
ID: InfoSelfServiceRecoveryEmailWithCodeSent,
|
|
Type: Info,
|
|
Text: "An email containing a recovery code has been sent to the email address you provided. If you have not received an email, check the spelling of the address and make sure to use the address you registered with.",
|
|
}
|
|
}
|
|
|
|
func NewRecoveryAskAnyRecoveryAddress() *Message {
|
|
return &Message{
|
|
ID: InfoNodeLabelRecoveryAddress,
|
|
Text: "Recovery address",
|
|
Type: Info,
|
|
}
|
|
}
|
|
|
|
func NewRecoveryCodeRecoverySelectAddressSent(maskedAddress string) *Message {
|
|
return &Message{
|
|
ID: InfoSelfServiceRecoveryMessageMaskedWithCodeSent,
|
|
Type: Info,
|
|
Text: fmt.Sprintf("A recovery code has been sent to %s. If you have not received it, check the spelling of the address and make sure to use the address you registered with.", maskedAddress),
|
|
Context: context(map[string]any{
|
|
"masked_address": maskedAddress,
|
|
}),
|
|
}
|
|
}
|
|
|
|
func NewRecoveryAskForFullAddress() *Message {
|
|
return &Message{
|
|
ID: InfoSelfServiceRecoveryAskForFullAddress,
|
|
Type: Info,
|
|
Text: "Recover access to your account by providing your recovery address in full.",
|
|
}
|
|
}
|
|
|
|
func NewRecoveryAskToChooseAddress() *Message {
|
|
return &Message{
|
|
ID: InfoSelfServiceRecoveryAskToChooseAddress,
|
|
Type: Info,
|
|
Text: "How do you want to recover your account?",
|
|
}
|
|
}
|
|
|
|
func NewRecoveryBack() *Message {
|
|
return &Message{
|
|
ID: InfoSelfServiceRecoveryBack,
|
|
Type: Info,
|
|
Text: "Back",
|
|
}
|
|
}
|
|
|
|
func NewErrorValidationRecoveryTokenInvalidOrAlreadyUsed() *Message {
|
|
return &Message{
|
|
ID: ErrorValidationRecoveryTokenInvalidOrAlreadyUsed,
|
|
Text: "The recovery token is invalid or has already been used. Please retry the flow.",
|
|
Type: Error,
|
|
}
|
|
}
|
|
|
|
func NewErrorValidationRecoveryCodeInvalidOrAlreadyUsed() *Message {
|
|
return &Message{
|
|
ID: ErrorValidationRecoveryCodeInvalidOrAlreadyUsed,
|
|
Text: "The recovery code is invalid or has already been used. Please try again.",
|
|
Type: Error,
|
|
}
|
|
}
|
|
|
|
func NewErrorValidationRecoveryRetrySuccess() *Message {
|
|
return &Message{
|
|
ID: ErrorValidationRecoveryRetrySuccess,
|
|
Text: "The request was already completed successfully and can not be retried.",
|
|
Type: Error,
|
|
}
|
|
}
|
|
|
|
func NewErrorValidationRecoveryStateFailure() *Message {
|
|
return &Message{
|
|
ID: ErrorValidationRecoveryStateFailure,
|
|
Text: "The recovery flow reached a failure state and must be retried.",
|
|
Type: Error,
|
|
}
|
|
}
|