forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MM-12736 Migrate MFA actions to redux (mattermost#1987)
* MM-12736 Migrate activateMfa/deactivateMfa/generateMfaSecret to be redux actions * MM-12736 Migrate checkMfa to be a redux action * Add unit tests * Fix prop type for SettingItemMax
- Loading branch information
Showing
18 changed files
with
346 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import * as UserActions from 'mattermost-redux/actions/users'; | ||
import {getConfig} from 'mattermost-redux/selectors/entities/general'; | ||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; | ||
|
||
export function activateMfa(code) { | ||
return (dispatch, getState) => { | ||
const currentUserId = getCurrentUserId(getState()); | ||
|
||
return dispatch(UserActions.updateUserMfa(currentUserId, true, code)); | ||
}; | ||
} | ||
|
||
export function deactivateMfa() { | ||
return (dispatch, getState) => { | ||
const currentUserId = getCurrentUserId(getState()); | ||
|
||
return dispatch(UserActions.updateUserMfa(currentUserId, false)); | ||
}; | ||
} | ||
|
||
export function generateMfaSecret() { | ||
return (dispatch, getState) => { | ||
const currentUserId = getCurrentUserId(getState()); | ||
|
||
return dispatch(UserActions.generateMfaSecret(currentUserId)); | ||
}; | ||
} | ||
|
||
export function checkMfa(loginId) { | ||
return (dispatch, getState) => { | ||
const config = getConfig(getState()); | ||
|
||
if (config.EnableMultifactorAuthentication !== 'true') { | ||
return Promise.resolve({data: false}); | ||
} | ||
|
||
return dispatch(UserActions.checkMfa(loginId)); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.