From 32dd13d43421b474db665224c9557386c352846a Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 19 Jul 2019 13:55:19 -0700 Subject: [PATCH] Modularize user activity log message types Summary: Depends on D20670. Ref T13343. The user activity message log types are currently hard-coded, so only upstream code can really use the log construct. Under the theory that we're going to keep this log around going forward (just focus it a little bit), modularize things so the log is extensible. Test Plan: Grepped for `UserLog::`, viewed activity logs in People and Settings. (If I missed something here -- say, misspelled a constant -- the effect should just be that older logs don't get a human-readable label, so stakes are very low.) Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13343 Differential Revision: https://secure.phabricator.com/D20671 --- src/__phutil_library_map__.php | 42 ++++++++++++++ .../engine/PhabricatorAuthSessionEngine.php | 16 +++--- .../PhabricatorPasswordAuthProvider.php | 2 +- .../ConduitGetCertificateConduitAPIMethod.php | 6 +- .../people/editor/PhabricatorUserEditor.php | 12 ++-- .../PhabricatorPeopleLogSearchEngine.php | 10 +++- .../people/storage/PhabricatorUserLog.php | 55 ------------------- .../PhabricatorAddEmailUserLogType.php | 12 ++++ .../PhabricatorAddMultifactorUserLogType.php | 12 ++++ .../PhabricatorChangePasswordUserLogType.php | 12 ++++ ...orConduitCertificateFailureUserLogType.php | 12 ++++ ...abricatorConduitCertificateUserLogType.php | 12 ++++ .../PhabricatorEnterHisecUserLogType.php | 12 ++++ .../PhabricatorExitHisecUserLogType.php | 12 ++++ .../PhabricatorFailHisecUserLogType.php | 12 ++++ .../PhabricatorFullLoginUserLogType.php | 12 ++++ .../PhabricatorLoginFailureUserLogType.php | 12 ++++ .../userlog/PhabricatorLoginUserLogType.php | 12 ++++ .../userlog/PhabricatorLogoutUserLogType.php | 12 ++++ .../PhabricatorPartialLoginUserLogType.php | 12 ++++ .../PhabricatorPrimaryEmailUserLogType.php | 12 ++++ .../PhabricatorReassignEmailUserLogType.php | 12 ++++ .../PhabricatorRemoveEmailUserLogType.php | 12 ++++ ...habricatorRemoveMultifactorUserLogType.php | 12 ++++ .../PhabricatorResetPasswordUserLogType.php | 12 ++++ .../PhabricatorSignDocumentsUserLogType.php | 12 ++++ .../people/userlog/PhabricatorUserLogType.php | 19 +++++++ .../PhabricatorVerifyEmailUserLogType.php | 12 ++++ .../people/view/PhabricatorUserLogView.php | 6 +- .../PhabricatorMultiFactorSettingsPanel.php | 4 +- 30 files changed, 332 insertions(+), 80 deletions(-) create mode 100644 src/applications/people/userlog/PhabricatorAddEmailUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorAddMultifactorUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorChangePasswordUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorConduitCertificateFailureUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorConduitCertificateUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorEnterHisecUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorExitHisecUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorFailHisecUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorFullLoginUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorLoginFailureUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorLoginUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorLogoutUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorPartialLoginUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorPrimaryEmailUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorReassignEmailUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorRemoveEmailUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorRemoveMultifactorUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorResetPasswordUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorSignDocumentsUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorUserLogType.php create mode 100644 src/applications/people/userlog/PhabricatorVerifyEmailUserLogType.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a82181acd7..a00b8e35c7 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2117,6 +2117,8 @@ phutil_register_library_map(array( 'PhabricatorActionListView' => 'view/layout/PhabricatorActionListView.php', 'PhabricatorActionView' => 'view/layout/PhabricatorActionView.php', 'PhabricatorActivitySettingsPanel' => 'applications/settings/panel/PhabricatorActivitySettingsPanel.php', + 'PhabricatorAddEmailUserLogType' => 'applications/people/userlog/PhabricatorAddEmailUserLogType.php', + 'PhabricatorAddMultifactorUserLogType' => 'applications/people/userlog/PhabricatorAddMultifactorUserLogType.php', 'PhabricatorAdministratorsPolicyRule' => 'applications/people/policyrule/PhabricatorAdministratorsPolicyRule.php', 'PhabricatorAjaxRequestExceptionHandler' => 'aphront/handler/PhabricatorAjaxRequestExceptionHandler.php', 'PhabricatorAlmanacApplication' => 'applications/almanac/application/PhabricatorAlmanacApplication.php', @@ -2668,6 +2670,7 @@ phutil_register_library_map(array( 'PhabricatorCelerityApplication' => 'applications/celerity/application/PhabricatorCelerityApplication.php', 'PhabricatorCelerityTestCase' => '__tests__/PhabricatorCelerityTestCase.php', 'PhabricatorChangeParserTestCase' => 'applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php', + 'PhabricatorChangePasswordUserLogType' => 'applications/people/userlog/PhabricatorChangePasswordUserLogType.php', 'PhabricatorChangesetCachePurger' => 'applications/cache/purger/PhabricatorChangesetCachePurger.php', 'PhabricatorChangesetResponse' => 'infrastructure/diff/PhabricatorChangesetResponse.php', 'PhabricatorChartAxis' => 'applications/fact/chart/PhabricatorChartAxis.php', @@ -2721,7 +2724,9 @@ phutil_register_library_map(array( 'PhabricatorConduitAPIController' => 'applications/conduit/controller/PhabricatorConduitAPIController.php', 'PhabricatorConduitApplication' => 'applications/conduit/application/PhabricatorConduitApplication.php', 'PhabricatorConduitCallManagementWorkflow' => 'applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php', + 'PhabricatorConduitCertificateFailureUserLogType' => 'applications/people/userlog/PhabricatorConduitCertificateFailureUserLogType.php', 'PhabricatorConduitCertificateToken' => 'applications/conduit/storage/PhabricatorConduitCertificateToken.php', + 'PhabricatorConduitCertificateUserLogType' => 'applications/people/userlog/PhabricatorConduitCertificateUserLogType.php', 'PhabricatorConduitConsoleController' => 'applications/conduit/controller/PhabricatorConduitConsoleController.php', 'PhabricatorConduitContentSource' => 'infrastructure/contentsource/PhabricatorConduitContentSource.php', 'PhabricatorConduitController' => 'applications/conduit/controller/PhabricatorConduitController.php', @@ -3224,6 +3229,7 @@ phutil_register_library_map(array( 'PhabricatorEmojiRemarkupRule' => 'applications/macro/markup/PhabricatorEmojiRemarkupRule.php', 'PhabricatorEmojiTranslation' => 'infrastructure/internationalization/translation/PhabricatorEmojiTranslation.php', 'PhabricatorEmptyQueryException' => 'infrastructure/query/exception/PhabricatorEmptyQueryException.php', + 'PhabricatorEnterHisecUserLogType' => 'applications/people/userlog/PhabricatorEnterHisecUserLogType.php', 'PhabricatorEnumConfigType' => 'applications/config/type/PhabricatorEnumConfigType.php', 'PhabricatorEnv' => 'infrastructure/env/PhabricatorEnv.php', 'PhabricatorEnvTestCase' => 'infrastructure/env/__tests__/PhabricatorEnvTestCase.php', @@ -3236,6 +3242,7 @@ phutil_register_library_map(array( 'PhabricatorExampleEventListener' => 'infrastructure/events/PhabricatorExampleEventListener.php', 'PhabricatorExcelExportFormat' => 'infrastructure/export/format/PhabricatorExcelExportFormat.php', 'PhabricatorExecFutureFileUploadSource' => 'applications/files/uploadsource/PhabricatorExecFutureFileUploadSource.php', + 'PhabricatorExitHisecUserLogType' => 'applications/people/userlog/PhabricatorExitHisecUserLogType.php', 'PhabricatorExportEngine' => 'infrastructure/export/engine/PhabricatorExportEngine.php', 'PhabricatorExportEngineBulkJobType' => 'infrastructure/export/engine/PhabricatorExportEngineBulkJobType.php', 'PhabricatorExportEngineExtension' => 'infrastructure/export/engine/PhabricatorExportEngineExtension.php', @@ -3276,6 +3283,7 @@ phutil_register_library_map(array( 'PhabricatorFactObjectDimension' => 'applications/fact/storage/PhabricatorFactObjectDimension.php', 'PhabricatorFactRaw' => 'applications/fact/storage/PhabricatorFactRaw.php', 'PhabricatorFactUpdateIterator' => 'applications/fact/extract/PhabricatorFactUpdateIterator.php', + 'PhabricatorFailHisecUserLogType' => 'applications/people/userlog/PhabricatorFailHisecUserLogType.php', 'PhabricatorFaviconRef' => 'applications/files/favicon/PhabricatorFaviconRef.php', 'PhabricatorFaviconRefQuery' => 'applications/files/favicon/PhabricatorFaviconRefQuery.php', 'PhabricatorFavoritesApplication' => 'applications/favorites/application/PhabricatorFavoritesApplication.php', @@ -3410,6 +3418,7 @@ phutil_register_library_map(array( 'PhabricatorFlaggableInterface' => 'applications/flag/interface/PhabricatorFlaggableInterface.php', 'PhabricatorFlagsApplication' => 'applications/flag/application/PhabricatorFlagsApplication.php', 'PhabricatorFlagsUIEventListener' => 'applications/flag/events/PhabricatorFlagsUIEventListener.php', + 'PhabricatorFullLoginUserLogType' => 'applications/people/userlog/PhabricatorFullLoginUserLogType.php', 'PhabricatorFulltextEngine' => 'applications/search/index/PhabricatorFulltextEngine.php', 'PhabricatorFulltextEngineExtension' => 'applications/search/index/PhabricatorFulltextEngineExtension.php', 'PhabricatorFulltextEngineExtensionModule' => 'applications/search/index/PhabricatorFulltextEngineExtensionModule.php', @@ -3548,7 +3557,10 @@ phutil_register_library_map(array( 'PhabricatorLockLogManagementWorkflow' => 'applications/daemon/management/PhabricatorLockLogManagementWorkflow.php', 'PhabricatorLockManagementWorkflow' => 'applications/daemon/management/PhabricatorLockManagementWorkflow.php', 'PhabricatorLogTriggerAction' => 'infrastructure/daemon/workers/action/PhabricatorLogTriggerAction.php', + 'PhabricatorLoginFailureUserLogType' => 'applications/people/userlog/PhabricatorLoginFailureUserLogType.php', + 'PhabricatorLoginUserLogType' => 'applications/people/userlog/PhabricatorLoginUserLogType.php', 'PhabricatorLogoutController' => 'applications/auth/controller/PhabricatorLogoutController.php', + 'PhabricatorLogoutUserLogType' => 'applications/people/userlog/PhabricatorLogoutUserLogType.php', 'PhabricatorLunarPhasePolicyRule' => 'applications/policy/rule/PhabricatorLunarPhasePolicyRule.php', 'PhabricatorMacroApplication' => 'applications/macro/application/PhabricatorMacroApplication.php', 'PhabricatorMacroAudioBehaviorTransaction' => 'applications/macro/xaction/PhabricatorMacroAudioBehaviorTransaction.php', @@ -3957,6 +3969,7 @@ phutil_register_library_map(array( 'PhabricatorPackagesVersionViewController' => 'applications/packages/controller/PhabricatorPackagesVersionViewController.php', 'PhabricatorPackagesView' => 'applications/packages/view/PhabricatorPackagesView.php', 'PhabricatorPagerUIExample' => 'applications/uiexample/examples/PhabricatorPagerUIExample.php', + 'PhabricatorPartialLoginUserLogType' => 'applications/people/userlog/PhabricatorPartialLoginUserLogType.php', 'PhabricatorPassphraseApplication' => 'applications/passphrase/application/PhabricatorPassphraseApplication.php', 'PhabricatorPasswordAuthProvider' => 'applications/auth/provider/PhabricatorPasswordAuthProvider.php', 'PhabricatorPasswordDestructionEngineExtension' => 'applications/auth/extension/PhabricatorPasswordDestructionEngineExtension.php', @@ -4145,6 +4158,7 @@ phutil_register_library_map(array( 'PhabricatorPolicyTestObject' => 'applications/policy/__tests__/PhabricatorPolicyTestObject.php', 'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php', 'PhabricatorPonderApplication' => 'applications/ponder/application/PhabricatorPonderApplication.php', + 'PhabricatorPrimaryEmailUserLogType' => 'applications/people/userlog/PhabricatorPrimaryEmailUserLogType.php', 'PhabricatorProfileMenuEditEngine' => 'applications/search/editor/PhabricatorProfileMenuEditEngine.php', 'PhabricatorProfileMenuEditor' => 'applications/search/editor/PhabricatorProfileMenuEditor.php', 'PhabricatorProfileMenuEngine' => 'applications/search/engine/PhabricatorProfileMenuEngine.php', @@ -4368,6 +4382,7 @@ phutil_register_library_map(array( 'PhabricatorQueryOrderTestCase' => 'infrastructure/query/order/__tests__/PhabricatorQueryOrderTestCase.php', 'PhabricatorQueryOrderVector' => 'infrastructure/query/order/PhabricatorQueryOrderVector.php', 'PhabricatorRateLimitRequestExceptionHandler' => 'aphront/handler/PhabricatorRateLimitRequestExceptionHandler.php', + 'PhabricatorReassignEmailUserLogType' => 'applications/people/userlog/PhabricatorReassignEmailUserLogType.php', 'PhabricatorRebuildIndexesWorker' => 'applications/search/worker/PhabricatorRebuildIndexesWorker.php', 'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php', 'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php', @@ -4386,6 +4401,8 @@ phutil_register_library_map(array( 'PhabricatorRemarkupFigletBlockInterpreter' => 'infrastructure/markup/interpreter/PhabricatorRemarkupFigletBlockInterpreter.php', 'PhabricatorRemarkupHyperlinkEngineExtension' => 'applications/remarkup/engineextension/PhabricatorRemarkupHyperlinkEngineExtension.php', 'PhabricatorRemarkupUIExample' => 'applications/uiexample/examples/PhabricatorRemarkupUIExample.php', + 'PhabricatorRemoveEmailUserLogType' => 'applications/people/userlog/PhabricatorRemoveEmailUserLogType.php', + 'PhabricatorRemoveMultifactorUserLogType' => 'applications/people/userlog/PhabricatorRemoveMultifactorUserLogType.php', 'PhabricatorRepositoriesSetupCheck' => 'applications/config/check/PhabricatorRepositoriesSetupCheck.php', 'PhabricatorRepository' => 'applications/repository/storage/PhabricatorRepository.php', 'PhabricatorRepositoryActivateTransaction' => 'applications/repository/xaction/PhabricatorRepositoryActivateTransaction.php', @@ -4524,6 +4541,7 @@ phutil_register_library_map(array( 'PhabricatorRepositoryVCSTransaction' => 'applications/repository/xaction/PhabricatorRepositoryVCSTransaction.php', 'PhabricatorRepositoryWorkingCopyVersion' => 'applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php', 'PhabricatorRequestExceptionHandler' => 'aphront/handler/PhabricatorRequestExceptionHandler.php', + 'PhabricatorResetPasswordUserLogType' => 'applications/people/userlog/PhabricatorResetPasswordUserLogType.php', 'PhabricatorResourceSite' => 'aphront/site/PhabricatorResourceSite.php', 'PhabricatorRobotsController' => 'applications/system/controller/PhabricatorRobotsController.php', 'PhabricatorS3FileStorageEngine' => 'applications/files/engine/PhabricatorS3FileStorageEngine.php', @@ -4630,6 +4648,7 @@ phutil_register_library_map(array( 'PhabricatorShiftChartFunction' => 'applications/fact/chart/PhabricatorShiftChartFunction.php', 'PhabricatorShortSite' => 'aphront/site/PhabricatorShortSite.php', 'PhabricatorShowFiletreeSetting' => 'applications/settings/setting/PhabricatorShowFiletreeSetting.php', + 'PhabricatorSignDocumentsUserLogType' => 'applications/people/userlog/PhabricatorSignDocumentsUserLogType.php', 'PhabricatorSimpleEditType' => 'applications/transactions/edittype/PhabricatorSimpleEditType.php', 'PhabricatorSinChartFunction' => 'applications/fact/chart/PhabricatorSinChartFunction.php', 'PhabricatorSite' => 'aphront/site/PhabricatorSite.php', @@ -4920,6 +4939,7 @@ phutil_register_library_map(array( 'PhabricatorUserFulltextEngine' => 'applications/people/search/PhabricatorUserFulltextEngine.php', 'PhabricatorUserIconField' => 'applications/people/customfield/PhabricatorUserIconField.php', 'PhabricatorUserLog' => 'applications/people/storage/PhabricatorUserLog.php', + 'PhabricatorUserLogType' => 'applications/people/userlog/PhabricatorUserLogType.php', 'PhabricatorUserLogView' => 'applications/people/view/PhabricatorUserLogView.php', 'PhabricatorUserMessageCountCacheType' => 'applications/people/cache/PhabricatorUserMessageCountCacheType.php', 'PhabricatorUserNotificationCountCacheType' => 'applications/people/cache/PhabricatorUserNotificationCountCacheType.php', @@ -4950,6 +4970,7 @@ phutil_register_library_map(array( 'PhabricatorUsersPolicyRule' => 'applications/people/policyrule/PhabricatorUsersPolicyRule.php', 'PhabricatorUsersSearchField' => 'applications/people/searchfield/PhabricatorUsersSearchField.php', 'PhabricatorVCSResponse' => 'applications/repository/response/PhabricatorVCSResponse.php', + 'PhabricatorVerifyEmailUserLogType' => 'applications/people/userlog/PhabricatorVerifyEmailUserLogType.php', 'PhabricatorVersionedDraft' => 'applications/draft/storage/PhabricatorVersionedDraft.php', 'PhabricatorVeryWowEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorVeryWowEnglishTranslation.php', 'PhabricatorVideoDocumentEngine' => 'applications/files/document/PhabricatorVideoDocumentEngine.php', @@ -8051,6 +8072,8 @@ phutil_register_library_map(array( 'PhabricatorActionListView' => 'AphrontTagView', 'PhabricatorActionView' => 'AphrontView', 'PhabricatorActivitySettingsPanel' => 'PhabricatorSettingsPanel', + 'PhabricatorAddEmailUserLogType' => 'PhabricatorUserLogType', + 'PhabricatorAddMultifactorUserLogType' => 'PhabricatorUserLogType', 'PhabricatorAdministratorsPolicyRule' => 'PhabricatorPolicyRule', 'PhabricatorAjaxRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', 'PhabricatorAlmanacApplication' => 'PhabricatorApplication', @@ -8716,6 +8739,7 @@ phutil_register_library_map(array( 'PhabricatorCelerityApplication' => 'PhabricatorApplication', 'PhabricatorCelerityTestCase' => 'PhabricatorTestCase', 'PhabricatorChangeParserTestCase' => 'PhabricatorWorkingCopyTestCase', + 'PhabricatorChangePasswordUserLogType' => 'PhabricatorUserLogType', 'PhabricatorChangesetCachePurger' => 'PhabricatorCachePurger', 'PhabricatorChangesetResponse' => 'AphrontProxyResponse', 'PhabricatorChartAxis' => 'Phobject', @@ -8774,7 +8798,9 @@ phutil_register_library_map(array( 'PhabricatorConduitAPIController' => 'PhabricatorConduitController', 'PhabricatorConduitApplication' => 'PhabricatorApplication', 'PhabricatorConduitCallManagementWorkflow' => 'PhabricatorConduitManagementWorkflow', + 'PhabricatorConduitCertificateFailureUserLogType' => 'PhabricatorUserLogType', 'PhabricatorConduitCertificateToken' => 'PhabricatorConduitDAO', + 'PhabricatorConduitCertificateUserLogType' => 'PhabricatorUserLogType', 'PhabricatorConduitConsoleController' => 'PhabricatorConduitController', 'PhabricatorConduitContentSource' => 'PhabricatorContentSource', 'PhabricatorConduitController' => 'PhabricatorController', @@ -9329,6 +9355,7 @@ phutil_register_library_map(array( 'PhabricatorEmojiRemarkupRule' => 'PhutilRemarkupRule', 'PhabricatorEmojiTranslation' => 'PhutilTranslation', 'PhabricatorEmptyQueryException' => 'Exception', + 'PhabricatorEnterHisecUserLogType' => 'PhabricatorUserLogType', 'PhabricatorEnumConfigType' => 'PhabricatorTextConfigType', 'PhabricatorEnv' => 'Phobject', 'PhabricatorEnvTestCase' => 'PhabricatorTestCase', @@ -9341,6 +9368,7 @@ phutil_register_library_map(array( 'PhabricatorExampleEventListener' => 'PhabricatorEventListener', 'PhabricatorExcelExportFormat' => 'PhabricatorExportFormat', 'PhabricatorExecFutureFileUploadSource' => 'PhabricatorFileUploadSource', + 'PhabricatorExitHisecUserLogType' => 'PhabricatorUserLogType', 'PhabricatorExportEngine' => 'Phobject', 'PhabricatorExportEngineBulkJobType' => 'PhabricatorWorkerSingleBulkJobType', 'PhabricatorExportEngineExtension' => 'Phobject', @@ -9386,6 +9414,7 @@ phutil_register_library_map(array( 'PhabricatorFactObjectDimension' => 'PhabricatorFactDimension', 'PhabricatorFactRaw' => 'PhabricatorFactDAO', 'PhabricatorFactUpdateIterator' => 'PhutilBufferedIterator', + 'PhabricatorFailHisecUserLogType' => 'PhabricatorUserLogType', 'PhabricatorFaviconRef' => 'Phobject', 'PhabricatorFaviconRefQuery' => 'Phobject', 'PhabricatorFavoritesApplication' => 'PhabricatorApplication', @@ -9557,6 +9586,7 @@ phutil_register_library_map(array( 'PhabricatorFlaggableInterface' => 'PhabricatorPHIDInterface', 'PhabricatorFlagsApplication' => 'PhabricatorApplication', 'PhabricatorFlagsUIEventListener' => 'PhabricatorEventListener', + 'PhabricatorFullLoginUserLogType' => 'PhabricatorUserLogType', 'PhabricatorFulltextEngine' => 'Phobject', 'PhabricatorFulltextEngineExtension' => 'Phobject', 'PhabricatorFulltextEngineExtensionModule' => 'PhabricatorConfigModule', @@ -9702,7 +9732,10 @@ phutil_register_library_map(array( 'PhabricatorLockLogManagementWorkflow' => 'PhabricatorLockManagementWorkflow', 'PhabricatorLockManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorLogTriggerAction' => 'PhabricatorTriggerAction', + 'PhabricatorLoginFailureUserLogType' => 'PhabricatorUserLogType', + 'PhabricatorLoginUserLogType' => 'PhabricatorUserLogType', 'PhabricatorLogoutController' => 'PhabricatorAuthController', + 'PhabricatorLogoutUserLogType' => 'PhabricatorUserLogType', 'PhabricatorLunarPhasePolicyRule' => 'PhabricatorPolicyRule', 'PhabricatorMacroApplication' => 'PhabricatorApplication', 'PhabricatorMacroAudioBehaviorTransaction' => 'PhabricatorMacroTransactionType', @@ -10182,6 +10215,7 @@ phutil_register_library_map(array( 'PhabricatorPackagesVersionViewController' => 'PhabricatorPackagesVersionController', 'PhabricatorPackagesView' => 'AphrontView', 'PhabricatorPagerUIExample' => 'PhabricatorUIExample', + 'PhabricatorPartialLoginUserLogType' => 'PhabricatorUserLogType', 'PhabricatorPassphraseApplication' => 'PhabricatorApplication', 'PhabricatorPasswordAuthProvider' => 'PhabricatorAuthProvider', 'PhabricatorPasswordDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension', @@ -10402,6 +10436,7 @@ phutil_register_library_map(array( ), 'PhabricatorPolicyType' => 'PhabricatorPolicyConstants', 'PhabricatorPonderApplication' => 'PhabricatorApplication', + 'PhabricatorPrimaryEmailUserLogType' => 'PhabricatorUserLogType', 'PhabricatorProfileMenuEditEngine' => 'PhabricatorEditEngine', 'PhabricatorProfileMenuEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorProfileMenuEngine' => 'Phobject', @@ -10669,6 +10704,7 @@ phutil_register_library_map(array( 'Iterator', ), 'PhabricatorRateLimitRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', + 'PhabricatorReassignEmailUserLogType' => 'PhabricatorUserLogType', 'PhabricatorRebuildIndexesWorker' => 'PhabricatorWorker', 'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorRedirectController' => 'PhabricatorController', @@ -10687,6 +10723,8 @@ phutil_register_library_map(array( 'PhabricatorRemarkupFigletBlockInterpreter' => 'PhutilRemarkupBlockInterpreter', 'PhabricatorRemarkupHyperlinkEngineExtension' => 'PhutilRemarkupHyperlinkEngineExtension', 'PhabricatorRemarkupUIExample' => 'PhabricatorUIExample', + 'PhabricatorRemoveEmailUserLogType' => 'PhabricatorUserLogType', + 'PhabricatorRemoveMultifactorUserLogType' => 'PhabricatorUserLogType', 'PhabricatorRepositoriesSetupCheck' => 'PhabricatorSetupCheck', 'PhabricatorRepository' => array( 'PhabricatorRepositoryDAO', @@ -10894,6 +10932,7 @@ phutil_register_library_map(array( 'PhabricatorRepositoryVCSTransaction' => 'PhabricatorRepositoryTransactionType', 'PhabricatorRepositoryWorkingCopyVersion' => 'PhabricatorRepositoryDAO', 'PhabricatorRequestExceptionHandler' => 'AphrontRequestExceptionHandler', + 'PhabricatorResetPasswordUserLogType' => 'PhabricatorUserLogType', 'PhabricatorResourceSite' => 'PhabricatorSite', 'PhabricatorRobotsController' => 'PhabricatorController', 'PhabricatorS3FileStorageEngine' => 'PhabricatorFileStorageEngine', @@ -11002,6 +11041,7 @@ phutil_register_library_map(array( 'PhabricatorShiftChartFunction' => 'PhabricatorChartFunction', 'PhabricatorShortSite' => 'PhabricatorSite', 'PhabricatorShowFiletreeSetting' => 'PhabricatorSelectSetting', + 'PhabricatorSignDocumentsUserLogType' => 'PhabricatorUserLogType', 'PhabricatorSimpleEditType' => 'PhabricatorEditType', 'PhabricatorSinChartFunction' => 'PhabricatorChartFunction', 'PhabricatorSite' => 'AphrontSite', @@ -11336,6 +11376,7 @@ phutil_register_library_map(array( 'PhabricatorUserDAO', 'PhabricatorPolicyInterface', ), + 'PhabricatorUserLogType' => 'Phobject', 'PhabricatorUserLogView' => 'AphrontView', 'PhabricatorUserMessageCountCacheType' => 'PhabricatorUserCacheType', 'PhabricatorUserNotificationCountCacheType' => 'PhabricatorUserCacheType', @@ -11371,6 +11412,7 @@ phutil_register_library_map(array( 'PhabricatorUsersPolicyRule' => 'PhabricatorPolicyRule', 'PhabricatorUsersSearchField' => 'PhabricatorSearchTokenizerField', 'PhabricatorVCSResponse' => 'AphrontResponse', + 'PhabricatorVerifyEmailUserLogType' => 'PhabricatorUserLogType', 'PhabricatorVersionedDraft' => 'PhabricatorDraftDAO', 'PhabricatorVeryWowEnglishTranslation' => 'PhutilTranslation', 'PhabricatorVideoDocumentEngine' => 'PhabricatorDocumentEngine', diff --git a/src/applications/auth/engine/PhabricatorAuthSessionEngine.php b/src/applications/auth/engine/PhabricatorAuthSessionEngine.php index 7d73cb194d..7358a61a40 100644 --- a/src/applications/auth/engine/PhabricatorAuthSessionEngine.php +++ b/src/applications/auth/engine/PhabricatorAuthSessionEngine.php @@ -294,8 +294,8 @@ final class PhabricatorAuthSessionEngine extends Phobject { null, $identity_phid, ($partial - ? PhabricatorUserLog::ACTION_LOGIN_PARTIAL - : PhabricatorUserLog::ACTION_LOGIN)); + ? PhabricatorPartialLoginUserLogType::LOGTYPE + : PhabricatorLoginUserLogType::LOGTYPE)); $log->setDetails( array( @@ -366,7 +366,7 @@ final class PhabricatorAuthSessionEngine extends Phobject { $log = PhabricatorUserLog::initializeNewLog( $user, $user->getPHID(), - PhabricatorUserLog::ACTION_LOGOUT); + PhabricatorLogoutUserLogType::LOGTYPE); $log->save(); $extensions = PhabricatorAuthSessionEngineExtension::getAllExtensions(); @@ -688,13 +688,13 @@ final class PhabricatorAuthSessionEngine extends Phobject { $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), - PhabricatorUserLog::ACTION_ENTER_HISEC); + PhabricatorEnterHisecUserLogType::LOGTYPE); $log->save(); } else { $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), - PhabricatorUserLog::ACTION_FAIL_HISEC); + PhabricatorFailHisecUserLogType::LOGTYPE); $log->save(); } } @@ -831,7 +831,7 @@ final class PhabricatorAuthSessionEngine extends Phobject { $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), - PhabricatorUserLog::ACTION_EXIT_HISEC); + PhabricatorExitHisecUserLogType::LOGTYPE); $log->save(); } @@ -872,7 +872,7 @@ final class PhabricatorAuthSessionEngine extends Phobject { $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), - PhabricatorUserLog::ACTION_LOGIN_FULL); + PhabricatorFullLoginUserLogType::LOGTYPE); $log->save(); unset($unguarded); } @@ -917,7 +917,7 @@ final class PhabricatorAuthSessionEngine extends Phobject { $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), - PhabricatorUserLog::ACTION_LOGIN_LEGALPAD); + PhabricatorSignDocumentsUserLogType::LOGTYPE); $log->save(); } unset($unguarded); diff --git a/src/applications/auth/provider/PhabricatorPasswordAuthProvider.php b/src/applications/auth/provider/PhabricatorPasswordAuthProvider.php index 215d316b3b..6b2681eea8 100644 --- a/src/applications/auth/provider/PhabricatorPasswordAuthProvider.php +++ b/src/applications/auth/provider/PhabricatorPasswordAuthProvider.php @@ -318,7 +318,7 @@ final class PhabricatorPasswordAuthProvider extends PhabricatorAuthProvider { $log = PhabricatorUserLog::initializeNewLog( null, $log_user ? $log_user->getPHID() : null, - PhabricatorUserLog::ACTION_LOGIN_FAILURE); + PhabricatorLoginFailureUserLogType::LOGTYPE); $log->save(); } diff --git a/src/applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php b/src/applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php index 6248b5a6ba..41716748e0 100644 --- a/src/applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php +++ b/src/applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php @@ -41,7 +41,7 @@ final class ConduitGetCertificateConduitAPIMethod extends ConduitAPIMethod { protected function execute(ConduitAPIRequest $request) { $failed_attempts = PhabricatorUserLog::loadRecentEventsFromThisIP( - PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE_FAILURE, + PhabricatorConduitCertificateFailureUserLogType::LOGTYPE, 60 * 5); if (count($failed_attempts) > 5) { @@ -61,7 +61,7 @@ final class ConduitGetCertificateConduitAPIMethod extends ConduitAPIMethod { $log = PhabricatorUserLog::initializeNewLog( $request->getUser(), $info->getUserPHID(), - PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE) + PhabricatorConduitCertificateUserLogType::LOGTYPE) ->save(); } @@ -85,7 +85,7 @@ final class ConduitGetCertificateConduitAPIMethod extends ConduitAPIMethod { $log = PhabricatorUserLog::initializeNewLog( $request->getUser(), $info ? $info->getUserPHID() : '-', - PhabricatorUserLog::ACTION_CONDUIT_CERTIFICATE_FAILURE) + PhabricatorConduitCertificateFailureUserLogType::LOGTYPE) ->save(); } diff --git a/src/applications/people/editor/PhabricatorUserEditor.php b/src/applications/people/editor/PhabricatorUserEditor.php index 9ab2c9d60b..81f427ada8 100644 --- a/src/applications/people/editor/PhabricatorUserEditor.php +++ b/src/applications/people/editor/PhabricatorUserEditor.php @@ -78,7 +78,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor { $log = PhabricatorUserLog::initializeNewLog( $this->requireActor(), $user->getPHID(), - PhabricatorUserLog::ACTION_EMAIL_REASSIGN); + PhabricatorReassignEmailUserLogType::LOGTYPE); $log->setNewValue($email->getAddress()); $log->save(); } @@ -195,7 +195,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor { $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), - PhabricatorUserLog::ACTION_EMAIL_ADD); + PhabricatorAddEmailUserLogType::LOGTYPE); $log->setNewValue($email->getAddress()); $log->save(); @@ -246,7 +246,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor { $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), - PhabricatorUserLog::ACTION_EMAIL_REMOVE); + PhabricatorRemoveEmailUserLogType::LOGTYPE); $log->setOldValue($email->getAddress()); $log->save(); @@ -312,7 +312,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor { $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), - PhabricatorUserLog::ACTION_EMAIL_PRIMARY); + PhabricatorPrimaryEmailUserLogType::LOGTYPE); $log->setOldValue($old_primary ? $old_primary->getAddress() : null); $log->setNewValue($email->getAddress()); @@ -371,7 +371,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor { $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), - PhabricatorUserLog::ACTION_EMAIL_VERIFY); + PhabricatorVerifyEmailUserLogType::LOGTYPE); $log->setNewValue($email->getAddress()); $log->save(); } @@ -433,7 +433,7 @@ final class PhabricatorUserEditor extends PhabricatorEditor { $log = PhabricatorUserLog::initializeNewLog( $actor, $user->getPHID(), - PhabricatorUserLog::ACTION_EMAIL_REASSIGN); + PhabricatorReassignEmailUserLogType::LOGTYPE); $log->setNewValue($email->getAddress()); $log->save(); } diff --git a/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php b/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php index b052456cd3..ad37395b88 100644 --- a/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php +++ b/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php @@ -64,6 +64,9 @@ final class PhabricatorPeopleLogSearchEngine } protected function buildCustomSearchFields() { + $types = PhabricatorUserLogType::getAllLogTypes(); + $types = mpull($types, 'getLogTypeName', 'getLogTypeKey'); + return array( id(new PhabricatorUsersSearchField()) ->setKey('userPHIDs') @@ -79,7 +82,7 @@ final class PhabricatorPeopleLogSearchEngine ->setKey('actions') ->setLabel(pht('Actions')) ->setDescription(pht('Search for particular types of activity.')) - ->setOptions(PhabricatorUserLog::getActionTypeMap()), + ->setOptions($types), id(new PhabricatorSearchTextField()) ->setKey('ip') ->setLabel(pht('Filter IP')) @@ -194,7 +197,8 @@ final class PhabricatorPeopleLogSearchEngine } $handles = $viewer->loadHandles($phids); - $action_map = PhabricatorUserLog::getActionTypeMap(); + $types = PhabricatorUserLogType::getAllLogTypes(); + $types = mpull($types, 'getLogTypeName', 'getLogTypeKey'); $export = array(); foreach ($logs as $log) { @@ -214,7 +218,7 @@ final class PhabricatorPeopleLogSearchEngine } $action = $log->getAction(); - $action_name = idx($action_map, $action, pht('Unknown ("%s")', $action)); + $action_name = idx($types, $action, pht('Unknown ("%s")', $action)); $map = array( 'actorPHID' => $actor_phid, diff --git a/src/applications/people/storage/PhabricatorUserLog.php b/src/applications/people/storage/PhabricatorUserLog.php index c7550ba8e5..d433ebca07 100644 --- a/src/applications/people/storage/PhabricatorUserLog.php +++ b/src/applications/people/storage/PhabricatorUserLog.php @@ -3,32 +3,6 @@ final class PhabricatorUserLog extends PhabricatorUserDAO implements PhabricatorPolicyInterface { - const ACTION_LOGIN = 'login'; - const ACTION_LOGIN_PARTIAL = 'login-partial'; - const ACTION_LOGIN_FULL = 'login-full'; - const ACTION_LOGOUT = 'logout'; - const ACTION_LOGIN_FAILURE = 'login-fail'; - const ACTION_LOGIN_LEGALPAD = 'login-legalpad'; - const ACTION_RESET_PASSWORD = 'reset-pass'; - - const ACTION_CONDUIT_CERTIFICATE = 'conduit-cert'; - const ACTION_CONDUIT_CERTIFICATE_FAILURE = 'conduit-cert-fail'; - - const ACTION_EMAIL_PRIMARY = 'email-primary'; - const ACTION_EMAIL_REMOVE = 'email-remove'; - const ACTION_EMAIL_ADD = 'email-add'; - const ACTION_EMAIL_VERIFY = 'email-verify'; - const ACTION_EMAIL_REASSIGN = 'email-reassign'; - - const ACTION_CHANGE_PASSWORD = 'change-password'; - - const ACTION_ENTER_HISEC = 'hisec-enter'; - const ACTION_EXIT_HISEC = 'hisec-exit'; - const ACTION_FAIL_HISEC = 'hisec-fail'; - - const ACTION_MULTI_ADD = 'multi-add'; - const ACTION_MULTI_REMOVE = 'multi-remove'; - protected $actorPHID; protected $userPHID; protected $action; @@ -38,35 +12,6 @@ final class PhabricatorUserLog extends PhabricatorUserDAO protected $remoteAddr; protected $session; - public static function getActionTypeMap() { - return array( - self::ACTION_LOGIN => pht('Login'), - self::ACTION_LOGIN_PARTIAL => pht('Login: Partial Login'), - self::ACTION_LOGIN_FULL => pht('Login: Upgrade to Full'), - self::ACTION_LOGIN_FAILURE => pht('Login: Failure'), - self::ACTION_LOGIN_LEGALPAD => - pht('Login: Signed Required Legalpad Documents'), - self::ACTION_LOGOUT => pht('Logout'), - self::ACTION_RESET_PASSWORD => pht('Reset Password'), - self::ACTION_CONDUIT_CERTIFICATE - => pht('Conduit: Read Certificate'), - self::ACTION_CONDUIT_CERTIFICATE_FAILURE - => pht('Conduit: Read Certificate Failure'), - self::ACTION_EMAIL_PRIMARY => pht('Email: Change Primary'), - self::ACTION_EMAIL_ADD => pht('Email: Add Address'), - self::ACTION_EMAIL_REMOVE => pht('Email: Remove Address'), - self::ACTION_EMAIL_VERIFY => pht('Email: Verify'), - self::ACTION_EMAIL_REASSIGN => pht('Email: Reassign'), - self::ACTION_CHANGE_PASSWORD => pht('Change Password'), - self::ACTION_ENTER_HISEC => pht('Hisec: Enter'), - self::ACTION_EXIT_HISEC => pht('Hisec: Exit'), - self::ACTION_FAIL_HISEC => pht('Hisec: Failed Attempt'), - self::ACTION_MULTI_ADD => pht('Multi-Factor: Add Factor'), - self::ACTION_MULTI_REMOVE => pht('Multi-Factor: Remove Factor'), - ); - } - - public static function initializeNewLog( PhabricatorUser $actor = null, $object_phid = null, diff --git a/src/applications/people/userlog/PhabricatorAddEmailUserLogType.php b/src/applications/people/userlog/PhabricatorAddEmailUserLogType.php new file mode 100644 index 0000000000..5587f46ed3 --- /dev/null +++ b/src/applications/people/userlog/PhabricatorAddEmailUserLogType.php @@ -0,0 +1,12 @@ +getPhobjectClassConstant('LOGTYPE', 32); + } + + abstract public function getLogTypeName(); + + final public static function getAllLogTypes() { + return id(new PhutilClassMapQuery()) + ->setAncestorClass(__CLASS__) + ->setUniqueMethod('getLogTypeKey') + ->execute(); + } + +} diff --git a/src/applications/people/userlog/PhabricatorVerifyEmailUserLogType.php b/src/applications/people/userlog/PhabricatorVerifyEmailUserLogType.php new file mode 100644 index 0000000000..b6f39a2e7b --- /dev/null +++ b/src/applications/people/userlog/PhabricatorVerifyEmailUserLogType.php @@ -0,0 +1,12 @@ +loadHandles($phids); - $action_map = PhabricatorUserLog::getActionTypeMap(); + $types = PhabricatorUserLogType::getAllLogTypes(); + $types = mpull($types, 'getLogTypeName', 'getLogTypeKey'); + $base_uri = $this->searchBaseURI; $viewer_phid = $viewer->getPHID(); @@ -69,7 +71,7 @@ final class PhabricatorUserLogView extends AphrontView { } $action = $log->getAction(); - $action_name = idx($action_map, $action, $action); + $action_name = idx($types, $action, $action); if ($actor_phid) { $actor_name = $handles[$actor_phid]->renderLink(); diff --git a/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php b/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php index abbb88c0a5..0054610c28 100644 --- a/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php @@ -315,7 +315,7 @@ final class PhabricatorMultiFactorSettingsPanel $log = PhabricatorUserLog::initializeNewLog( $viewer, $user->getPHID(), - PhabricatorUserLog::ACTION_MULTI_ADD); + PhabricatorAddMultifactorUserLogType::LOGTYPE); $log->save(); $user->updateMultiFactorEnrollment(); @@ -423,7 +423,7 @@ final class PhabricatorMultiFactorSettingsPanel $log = PhabricatorUserLog::initializeNewLog( $viewer, $user->getPHID(), - PhabricatorUserLog::ACTION_MULTI_REMOVE); + PhabricatorRemoveMultifactorUserLogType::LOGTYPE); $log->save(); $user->updateMultiFactorEnrollment();