feat(identity): confirm the email address with a six-digit code from the message

This commit is contained in:
shira committed 2026-10-10 00:52:46 +03:00
1 parent c94434cd09
commit d365a05c96
87 files changed
+4764 -224

No files matched your search

@@ -15417,6 +15417,82 @@ func (s *ConfirmEmailBadRequest) UnmarshalJSON(data []byte) error {
return s.Decode(d)
}
// Encode encodes ConfirmEmailByCodeBadRequest as json.
func (s *ConfirmEmailByCodeBadRequest) Encode(e *jx.Encoder) {
unwrapped := (*Problem)(s)
unwrapped.Encode(e)
}
// Decode decodes ConfirmEmailByCodeBadRequest from json.
func (s *ConfirmEmailByCodeBadRequest) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode ConfirmEmailByCodeBadRequest to nil")
}
var unwrapped Problem
if err := func() error {
if err := unwrapped.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "alias")
}
*s = ConfirmEmailByCodeBadRequest(unwrapped)
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s *ConfirmEmailByCodeBadRequest) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ConfirmEmailByCodeBadRequest) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode encodes ConfirmEmailByCodeForbidden as json.
func (s *ConfirmEmailByCodeForbidden) Encode(e *jx.Encoder) {
unwrapped := (*Problem)(s)
unwrapped.Encode(e)
}
// Decode decodes ConfirmEmailByCodeForbidden from json.
func (s *ConfirmEmailByCodeForbidden) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode ConfirmEmailByCodeForbidden to nil")
}
var unwrapped Problem
if err := func() error {
if err := unwrapped.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "alias")
}
*s = ConfirmEmailByCodeForbidden(unwrapped)
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s *ConfirmEmailByCodeForbidden) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ConfirmEmailByCodeForbidden) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode encodes ConfirmEmailForbidden as json.
func (s *ConfirmEmailForbidden) Encode(e *jx.Encoder) {
unwrapped := (*Problem)(s)
@@ -19271,6 +19347,132 @@ func (s *EmailAddress) UnmarshalJSON(data []byte) error {
return s.Decode(d)
}
// Encode implements json.Marshaler.
func (s *EmailVerificationCodeRequest) Encode(e *jx.Encoder) {
e.ObjStart()
s.encodeFields(e)
e.ObjEnd()
}
// encodeFields encodes fields.
func (s *EmailVerificationCodeRequest) encodeFields(e *jx.Encoder) {
{
e.FieldStart("email")
s.Email.Encode(e)
}
{
e.FieldStart("code")
s.Code.Encode(e)
}
{
e.FieldStart("password")
e.Str(s.Password)
}
}
var jsonFieldsNameOfEmailVerificationCodeRequest = [3]string{
0: "email",
1: "code",
2: "password",
}
// Decode decodes EmailVerificationCodeRequest from json.
func (s *EmailVerificationCodeRequest) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode EmailVerificationCodeRequest to nil")
}
var requiredBitSet [1]uint8
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
switch string(k) {
case "email":
requiredBitSet[0] |= 1 << 0
if err := func() error {
if err := s.Email.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"email\"")
}
case "code":
requiredBitSet[0] |= 1 << 1
if err := func() error {
if err := s.Code.Decode(d); err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"code\"")
}
case "password":
requiredBitSet[0] |= 1 << 2
if err := func() error {
v, err := d.Str()
s.Password = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "decode field \"password\"")
}
default:
return errors.Errorf("unexpected field %q", k)
}
return nil
}); err != nil {
return errors.Wrap(err, "decode EmailVerificationCodeRequest")
}
// Validate required fields.
var failures []validate.FieldError
for i, mask := range [1]uint8{
0b00000111,
} {
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
// Mask only required fields and check equality to mask using XOR.
//
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
// Bits of fields which would be set are actually bits of missed fields.
missed := bits.OnesCount8(result)
for bitN := 0; bitN < missed; bitN++ {
bitIdx := bits.TrailingZeros8(result)
fieldIdx := i*8 + bitIdx
var name string
if fieldIdx < len(jsonFieldsNameOfEmailVerificationCodeRequest) {
name = jsonFieldsNameOfEmailVerificationCodeRequest[fieldIdx]
} else {
name = strconv.Itoa(fieldIdx)
}
failures = append(failures, validate.FieldError{
Name: name,
Error: validate.ErrFieldRequired,
})
// Reset bit.
result &^= 1 << bitIdx
}
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s *EmailVerificationCodeRequest) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *EmailVerificationCodeRequest) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode implements json.Marshaler.
func (s *EmailVerificationRequest) Encode(e *jx.Encoder) {
e.ObjStart()
@@ -62758,6 +62960,46 @@ func (s *UpdateOrganizationUnauthorized) UnmarshalJSON(data []byte) error {
return s.Decode(d)
}
// Encode encodes VerificationCode as json.
func (s VerificationCode) Encode(e *jx.Encoder) {
unwrapped := string(s)
e.Str(unwrapped)
}
// Decode decodes VerificationCode from json.
func (s *VerificationCode) Decode(d *jx.Decoder) error {
if s == nil {
return errors.New("invalid: unable to decode VerificationCode to nil")
}
var unwrapped string
if err := func() error {
v, err := d.Str()
unwrapped = string(v)
if err != nil {
return err
}
return nil
}(); err != nil {
return errors.Wrap(err, "alias")
}
*s = VerificationCode(unwrapped)
return nil
}
// MarshalJSON implements stdjson.Marshaler.
func (s VerificationCode) MarshalJSON() ([]byte, error) {
e := jx.Encoder{}
s.Encode(&e)
return e.Bytes(), nil
}
// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *VerificationCode) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data)
return s.Decode(d)
}
// Encode encodes VerificationToken as json.
func (s VerificationToken) Encode(e *jx.Encoder) {
unwrapped := string(s)