updated the rules when linking OAuth2 by email

This commit is contained in:
Gani Georgiev
2024-06-18 16:15:53 +03:00
parent af9cf33553
commit 58ace5d5e7
53 changed files with 637 additions and 351 deletions

View File

@@ -309,7 +309,7 @@ func (m *Record) Set(key string, value any) {
switch key {
case schema.FieldNameEmailVisibility, schema.FieldNameVerified:
v = cast.ToBool(value)
case schema.FieldNameLastResetSentAt, schema.FieldNameLastVerificationSentAt:
case schema.FieldNameLastResetSentAt, schema.FieldNameLastVerificationSentAt, schema.FieldNameLastLoginAlertSentAt:
v, _ = types.ParseDateTime(value)
case schema.FieldNameUsername, schema.FieldNameEmail, schema.FieldNameTokenKey, schema.FieldNamePasswordHash:
v = cast.ToString(value)
@@ -347,7 +347,7 @@ func (m *Record) Get(key string) any {
switch key {
case schema.FieldNameEmailVisibility, schema.FieldNameVerified:
v = cast.ToBool(v)
case schema.FieldNameLastResetSentAt, schema.FieldNameLastVerificationSentAt:
case schema.FieldNameLastResetSentAt, schema.FieldNameLastVerificationSentAt, schema.FieldNameLastLoginAlertSentAt:
v, _ = types.ParseDateTime(v)
case schema.FieldNameUsername, schema.FieldNameEmail, schema.FieldNameTokenKey, schema.FieldNamePasswordHash:
v = cast.ToString(v)
@@ -685,7 +685,7 @@ func (m *Record) getNormalizeDataValueForDB(key string) any {
switch key {
case schema.FieldNameEmailVisibility, schema.FieldNameVerified:
return m.GetBool(key)
case schema.FieldNameLastResetSentAt, schema.FieldNameLastVerificationSentAt:
case schema.FieldNameLastResetSentAt, schema.FieldNameLastVerificationSentAt, schema.FieldNameLastLoginAlertSentAt:
return m.GetDateTime(key)
case schema.FieldNameUsername, schema.FieldNameEmail, schema.FieldNameTokenKey, schema.FieldNamePasswordHash:
return m.GetString(key)
@@ -898,6 +898,24 @@ func (m *Record) SetLastVerificationSentAt(dateTime types.DateTime) error {
return nil
}
// LastLoginAlertSentAt returns the "lastLoginAlertSentAt" auth record data value.
func (m *Record) LastLoginAlertSentAt() types.DateTime {
return m.GetDateTime(schema.FieldNameLastLoginAlertSentAt)
}
// SetLastLoginAlertSentAt sets an "lastLoginAlertSentAt" auth record data value.
//
// Returns an error if the record is not from an auth collection.
func (m *Record) SetLastLoginAlertSentAt(dateTime types.DateTime) error {
if !m.collection.IsAuth() {
return notAuthRecordErr
}
m.Set(schema.FieldNameLastLoginAlertSentAt, dateTime)
return nil
}
// PasswordHash returns the "passwordHash" auth record data value.
func (m *Record) PasswordHash() string {
return m.GetString(schema.FieldNamePasswordHash)