diff --git a/cmd/authelia-scripts/migration_local.go b/cmd/authelia-scripts/migration_local.go index dee69c8cd..8a39bbefe 100644 --- a/cmd/authelia-scripts/migration_local.go +++ b/cmd/authelia-scripts/migration_local.go @@ -102,7 +102,7 @@ func migrateLocalU2FSecret(dbProvider storage.Provider) { } func migrateLocalPreferences(dbProvider storage.Provider) { - file, err := os.Open(path.Join(localDatabasePath, "prefered_2fa_method")) + file, err := os.Open(path.Join(localDatabasePath, "preferred_2fa_method")) if err != nil { log.Fatal(err) } @@ -115,7 +115,7 @@ func migrateLocalPreferences(dbProvider storage.Provider) { entry := PreferencesV3{} json.Unmarshal([]byte(data), &entry) - err := dbProvider.SavePrefered2FAMethod(entry.UserID, entry.Method) + err := dbProvider.SavePreferred2FAMethod(entry.UserID, entry.Method) if err != nil { log.Fatal(err) diff --git a/cmd/authelia-scripts/migration_mongo.go b/cmd/authelia-scripts/migration_mongo.go index afac9af36..baa61055b 100644 --- a/cmd/authelia-scripts/migration_mongo.go +++ b/cmd/authelia-scripts/migration_mongo.go @@ -124,7 +124,7 @@ func migrateMongoTOTPDevices(db *mongo.Database, dbProvider storage.Provider) { } func migrateMongoPreferences(db *mongo.Database, dbProvider storage.Provider) { - u2fCollection := db.Collection("prefered_2fa_method") + u2fCollection := db.Collection("preferred_2fa_method") cur, err := u2fCollection.Find(context.Background(), bson.D{}) if err != nil { @@ -139,7 +139,7 @@ func migrateMongoPreferences(db *mongo.Database, dbProvider storage.Provider) { log.Fatal(err) } - err = dbProvider.SavePrefered2FAMethod(result.UserID, result.Method) + err = dbProvider.SavePreferred2FAMethod(result.UserID, result.Method) if err != nil { log.Fatal(err) diff --git a/internal/configuration/schema/notifier.go b/internal/configuration/schema/notifier.go index af51a9bd9..2e5565c5c 100644 --- a/internal/configuration/schema/notifier.go +++ b/internal/configuration/schema/notifier.go @@ -23,7 +23,7 @@ type SMTPNotifierConfiguration struct { Secure bool `yaml:"secure"` } -// NotifierConfiguration representes the configuration of the notifier to use when sending notifications to users. +// NotifierConfiguration represents the configuration of the notifier to use when sending notifications to users. type NotifierConfiguration struct { FileSystem *FileSystemNotifierConfiguration `yaml:"filesystem"` Email *EmailNotifierConfiguration `yaml:"email"` diff --git a/internal/handlers/handler_extended_configuration.go b/internal/handlers/handler_extended_configuration.go index 04e2ee5e6..8aa4f73bd 100644 --- a/internal/handlers/handler_extended_configuration.go +++ b/internal/handlers/handler_extended_configuration.go @@ -9,7 +9,7 @@ type ExtendedConfigurationBody struct { AvailableMethods MethodList `json:"available_methods"` } -// ExtendedConfigurationGet get the extended configuration accessbile to authenticated users. +// ExtendedConfigurationGet get the extended configuration accessible to authenticated users. func ExtendedConfigurationGet(ctx *middlewares.AutheliaCtx) { body := ExtendedConfigurationBody{} body.AvailableMethods = MethodList{authentication.TOTP, authentication.U2F} diff --git a/internal/handlers/handler_user_info.go b/internal/handlers/handler_user_info.go index 1f67f24f1..3ca3f3c59 100644 --- a/internal/handlers/handler_user_info.go +++ b/internal/handlers/handler_user_info.go @@ -19,7 +19,7 @@ func loadInfo(username string, storageProvier storage.Provider, preferences *Use errors := make([]error, 0) go func() { defer wg.Done() - method, err := storageProvier.LoadPrefered2FAMethod(username) + method, err := storageProvier.LoadPreferred2FAMethod(username) if err != nil { errors = append(errors, err) logger.Error(err) @@ -97,11 +97,11 @@ func MethodPreferencePost(ctx *middlewares.AutheliaCtx) { } userSession := ctx.GetSession() - ctx.Logger.Debugf("Save new prefered 2FA method of user %s to %s", userSession.Username, bodyJSON.Method) - err = ctx.Providers.StorageProvider.SavePrefered2FAMethod(userSession.Username, bodyJSON.Method) + ctx.Logger.Debugf("Save new preferred 2FA method of user %s to %s", userSession.Username, bodyJSON.Method) + err = ctx.Providers.StorageProvider.SavePreferred2FAMethod(userSession.Username, bodyJSON.Method) if err != nil { - ctx.Error(fmt.Errorf("Unable to save new prefered 2FA method: %s", err), operationFailedMessage) + ctx.Error(fmt.Errorf("Unable to save new preferred 2FA method: %s", err), operationFailedMessage) return } diff --git a/internal/handlers/handler_user_info_test.go b/internal/handlers/handler_user_info_test.go index 19e472ee8..102a62845 100644 --- a/internal/handlers/handler_user_info_test.go +++ b/internal/handlers/handler_user_info_test.go @@ -20,7 +20,7 @@ type FetchSuite struct { func (s *FetchSuite) SetupTest() { s.mock = mocks.NewMockAutheliaCtx(s.T()) - // Set the intial user session. + // Set the initial user session. userSession := s.mock.Ctx.GetSession() userSession.Username = "john" userSession.AuthenticationLevel = 1 @@ -34,7 +34,7 @@ func (s *FetchSuite) TearDownTest() { func setPreferencesExpectations(preferences UserPreferences, provider *storage.MockProvider) { provider. EXPECT(). - LoadPrefered2FAMethod(gomock.Eq("john")). + LoadPreferred2FAMethod(gomock.Eq("john")). Return(preferences.Method, nil) if preferences.HasU2F { @@ -89,7 +89,7 @@ func TestMethodSetToU2F(t *testing.T) { for _, expectedPreferences := range table { mock := mocks.NewMockAutheliaCtx(t) - // Set the intial user session. + // Set the initial user session. userSession := mock.Ctx.GetSession() userSession.Username = "john" userSession.AuthenticationLevel = 1 @@ -119,7 +119,7 @@ func TestMethodSetToU2F(t *testing.T) { func (s *FetchSuite) TestShouldGetDefaultPreferenceIfNotInDB() { s.mock.StorageProviderMock. EXPECT(). - LoadPrefered2FAMethod(gomock.Eq("john")). + LoadPreferred2FAMethod(gomock.Eq("john")). Return("", nil) s.mock.StorageProviderMock. @@ -138,7 +138,7 @@ func (s *FetchSuite) TestShouldGetDefaultPreferenceIfNotInDB() { func (s *FetchSuite) TestShouldReturnError500WhenStorageFailsToLoad() { s.mock.StorageProviderMock.EXPECT(). - LoadPrefered2FAMethod(gomock.Eq("john")). + LoadPreferred2FAMethod(gomock.Eq("john")). Return("", fmt.Errorf("Failure")) s.mock.StorageProviderMock. @@ -167,7 +167,7 @@ type SaveSuite struct { func (s *SaveSuite) SetupTest() { s.mock = mocks.NewMockAutheliaCtx(s.T()) - // Set the intial user session. + // Set the initial user session. userSession := s.mock.Ctx.GetSession() userSession.Username = "john" userSession.AuthenticationLevel = 1 @@ -217,20 +217,20 @@ func (s *SaveSuite) TestShouldReturnError500WhenBadMethodProvided() { func (s *SaveSuite) TestShouldReturnError500WhenDatabaseFailsToSave() { s.mock.Ctx.Request.SetBody([]byte("{\"method\":\"u2f\"}")) s.mock.StorageProviderMock.EXPECT(). - SavePrefered2FAMethod(gomock.Eq("john"), gomock.Eq("u2f")). + SavePreferred2FAMethod(gomock.Eq("john"), gomock.Eq("u2f")). Return(fmt.Errorf("Failure")) MethodPreferencePost(s.mock.Ctx) s.mock.Assert200KO(s.T(), "Operation failed.") - assert.Equal(s.T(), "Unable to save new prefered 2FA method: Failure", s.mock.Hook.LastEntry().Message) + assert.Equal(s.T(), "Unable to save new preferred 2FA method: Failure", s.mock.Hook.LastEntry().Message) assert.Equal(s.T(), logrus.ErrorLevel, s.mock.Hook.LastEntry().Level) } func (s *SaveSuite) TestShouldReturn200WhenMethodIsSuccessfullySaved() { s.mock.Ctx.Request.SetBody([]byte("{\"method\":\"u2f\"}")) s.mock.StorageProviderMock.EXPECT(). - SavePrefered2FAMethod(gomock.Eq("john"), gomock.Eq("u2f")). + SavePreferred2FAMethod(gomock.Eq("john"), gomock.Eq("u2f")). Return(nil) MethodPreferencePost(s.mock.Ctx) diff --git a/internal/handlers/types.go b/internal/handlers/types.go index becb6d02e..de030ac8d 100644 --- a/internal/handlers/types.go +++ b/internal/handlers/types.go @@ -12,7 +12,7 @@ type authorizationMatching int // UserInfo is the model of user second factor preferences type UserPreferences struct { - // The prefered 2FA method. + // The preferred 2FA method. Method string `json:"method" valid:"required"` // True if a security key has been registered diff --git a/internal/notification/smtp_notifier.go b/internal/notification/smtp_notifier.go index f94c11c3e..20031d4ef 100644 --- a/internal/notification/smtp_notifier.go +++ b/internal/notification/smtp_notifier.go @@ -51,7 +51,7 @@ func (n *SMTPNotifier) Send(recipient string, subject string, body string) error return err } - // Do StartTLS if available (some servers only provide the auth extnesion after, and encrpytion is preferred) + // Do StartTLS if available (some servers only provide the auth extnesion after, and encryption is preferred) starttls, _ := c.Extension("STARTTLS") if starttls { tlsconfig := &tls.Config{ diff --git a/internal/regulation/regulator_test.go b/internal/regulation/regulator_test.go index 53f0e6c4a..8731dba69 100644 --- a/internal/regulation/regulator_test.go +++ b/internal/regulation/regulator_test.go @@ -227,7 +227,7 @@ func (s *RegulatorSuite) TestShouldCheckRegulationHasBeenResetOnSuccessfulAttemp Time: s.clock.Now().Add(-93 * time.Second), }, // The user was almost banned but he did a successful attempt. Therefore, even if the next - // failure happens withing FindTime, he should not be banned. + // failure happens within FindTime, he should not be banned. models.AuthenticationAttempt{ Username: "john", Successful: false, diff --git a/internal/storage/provider.go b/internal/storage/provider.go index 239a5337c..5579e285d 100644 --- a/internal/storage/provider.go +++ b/internal/storage/provider.go @@ -9,8 +9,8 @@ import ( // Provider is an interface providing storage capabilities for // persisting any kind of data related to Authelia. type Provider interface { - LoadPrefered2FAMethod(username string) (string, error) - SavePrefered2FAMethod(username string, method string) error + LoadPreferred2FAMethod(username string) (string, error) + SavePreferred2FAMethod(username string, method string) error FindIdentityVerificationToken(token string) (bool, error) SaveIdentityVerificationToken(token string) error diff --git a/internal/storage/provider_mock.go b/internal/storage/provider_mock.go index c13adb018..9126e4897 100644 --- a/internal/storage/provider_mock.go +++ b/internal/storage/provider_mock.go @@ -34,33 +34,33 @@ func (m *MockProvider) EXPECT() *MockProviderMockRecorder { return m.recorder } -// LoadPrefered2FAMethod mocks base method -func (m *MockProvider) LoadPrefered2FAMethod(username string) (string, error) { +// LoadPreferred2FAMethod mocks base method +func (m *MockProvider) LoadPreferred2FAMethod(username string) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LoadPrefered2FAMethod", username) + ret := m.ctrl.Call(m, "LoadPreferred2FAMethod", username) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } -// LoadPrefered2FAMethod indicates an expected call of LoadPrefered2FAMethod -func (mr *MockProviderMockRecorder) LoadPrefered2FAMethod(username interface{}) *gomock.Call { +// LoadPreferred2FAMethod indicates an expected call of LoadPreferred2FAMethod +func (mr *MockProviderMockRecorder) LoadPreferred2FAMethod(username interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadPrefered2FAMethod", reflect.TypeOf((*MockProvider)(nil).LoadPrefered2FAMethod), username) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadPreferred2FAMethod", reflect.TypeOf((*MockProvider)(nil).LoadPreferred2FAMethod), username) } -// SavePrefered2FAMethod mocks base method -func (m *MockProvider) SavePrefered2FAMethod(username, method string) error { +// SavePreferred2FAMethod mocks base method +func (m *MockProvider) SavePreferred2FAMethod(username, method string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SavePrefered2FAMethod", username, method) + ret := m.ctrl.Call(m, "SavePreferred2FAMethod", username, method) ret0, _ := ret[0].(error) return ret0 } -// SavePrefered2FAMethod indicates an expected call of SavePrefered2FAMethod -func (mr *MockProviderMockRecorder) SavePrefered2FAMethod(username, method interface{}) *gomock.Call { +// SavePreferred2FAMethod indicates an expected call of SavePreferred2FAMethod +func (mr *MockProviderMockRecorder) SavePreferred2FAMethod(username, method interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePrefered2FAMethod", reflect.TypeOf((*MockProvider)(nil).SavePrefered2FAMethod), username, method) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePreferred2FAMethod", reflect.TypeOf((*MockProvider)(nil).SavePreferred2FAMethod), username, method) } // FindIdentityVerificationToken mocks base method diff --git a/internal/storage/sql_provider.go b/internal/storage/sql_provider.go index e1fe30cc3..5bf8d0c8f 100644 --- a/internal/storage/sql_provider.go +++ b/internal/storage/sql_provider.go @@ -72,8 +72,8 @@ func (p *SQLProvider) initialize(db *sql.DB) error { return nil } -// LoadPrefered2FAMethod load the prefered method for 2FA from sqlite db. -func (p *SQLProvider) LoadPrefered2FAMethod(username string) (string, error) { +// LoadPreferred2FAMethod load the preferred method for 2FA from sqlite db. +func (p *SQLProvider) LoadPreferred2FAMethod(username string) (string, error) { rows, err := p.db.Query(p.sqlGetPreferencesByUsername, username) defer rows.Close() if err != nil { @@ -90,8 +90,8 @@ func (p *SQLProvider) LoadPrefered2FAMethod(username string) (string, error) { return "", nil } -// SavePrefered2FAMethod save the prefered method for 2FA in sqlite db. -func (p *SQLProvider) SavePrefered2FAMethod(username string, method string) error { +// SavePreferred2FAMethod save the preferred method for 2FA in sqlite db. +func (p *SQLProvider) SavePreferred2FAMethod(username string, method string) error { _, err := p.db.Exec(p.sqlUpsertSecondFactorPreference, username, method) return err } diff --git a/internal/templates/email.go b/internal/templates/email.go index 7c161ff5b..df49a9660 100644 --- a/internal/templates/email.go +++ b/internal/templates/email.go @@ -264,9 +264,9 @@ const emailContent = ` - + + st-sortable="separator">
@@ -281,7 +281,7 @@ const emailContent = `
- + @@ -353,9 +353,9 @@ const emailContent = `
- + + st-sortable="separator">
@@ -377,7 +377,7 @@ const emailContent = `
- + diff --git a/web/src/services/UserPreferences.ts b/web/src/services/UserPreferences.ts index c5be10578..471a3f304 100644 --- a/web/src/services/UserPreferences.ts +++ b/web/src/services/UserPreferences.ts @@ -42,7 +42,7 @@ export async function getUserPreferences(): Promise { return { ...res, method: toEnum(res.method) }; } -export function setPrefered2FAMethod(method: SecondFactorMethod) { +export function setPreferred2FAMethod(method: SecondFactorMethod) { return PostWithOptionalResponse(UserInfo2FAMethodPath, { method: toString(method) } as MethodPreferencePayload); } \ No newline at end of file diff --git a/web/src/views/LoginPortal/SecondFactor/SecondFactorForm.tsx b/web/src/views/LoginPortal/SecondFactor/SecondFactorForm.tsx index b6472bb0e..62b4994cc 100644 --- a/web/src/views/LoginPortal/SecondFactor/SecondFactorForm.tsx +++ b/web/src/views/LoginPortal/SecondFactor/SecondFactorForm.tsx @@ -16,7 +16,7 @@ import { LogoutRoute as SignOutRoute, SecondFactorTOTPRoute, SecondFactorPushRoute, SecondFactorU2FRoute, SecondFactorRoute } from "../../../Routes"; -import { setPrefered2FAMethod } from "../../../services/UserPreferences"; +import { setPreferred2FAMethod } from "../../../services/UserPreferences"; import { UserInfo } from "../../../models/UserInfo"; import { ExtendedConfiguration } from "../../../models/Configuration"; import u2fApi from "u2f-api"; @@ -69,12 +69,12 @@ export default function (props: Props) { const handleMethodSelected = async (method: SecondFactorMethod) => { try { - await setPrefered2FAMethod(method); + await setPreferred2FAMethod(method); setMethodSelectionOpen(false); props.onMethodChanged(method); } catch (err) { console.error(err); - createErrorNotification("There was an issue updating prefered second factor method"); + createErrorNotification("There was an issue updating preferred second factor method"); } }