Save credentials immediately after login (#1703)
* Save credentials immediately after login * Add mock app class to login.test.js
This commit is contained in:
parent
dd346dbd75
commit
5604836a9d
2 changed files with 14 additions and 1 deletions
|
|
@ -4,8 +4,10 @@
|
|||
import {getDataRetentionPolicy} from 'mattermost-redux/actions/general';
|
||||
import {GeneralTypes} from 'mattermost-redux/action_types';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
import {ViewTypes} from 'app/constants';
|
||||
import {app} from 'app/mattermost';
|
||||
|
||||
export function handleLoginIdChanged(loginId) {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
@ -27,9 +29,14 @@ export function handlePasswordChanged(password) {
|
|||
|
||||
export function handleSuccessfulLogin() {
|
||||
return async (dispatch, getState) => {
|
||||
const {config, license} = getState().entities.general;
|
||||
const state = getState();
|
||||
const {config, license} = state.entities.general;
|
||||
const token = Client4.getToken();
|
||||
const url = Client4.getUrl();
|
||||
const deviceToken = state.entities.general.deviceToken;
|
||||
const currentUserId = getCurrentUserId(state);
|
||||
|
||||
app.setAppCredentials(deviceToken, currentUserId, token, url);
|
||||
|
||||
dispatch({
|
||||
type: GeneralTypes.RECEIVED_APP_CREDENTIALS,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ jest.mock('react-native-fetch-blob/fs', () => ({
|
|||
},
|
||||
}));
|
||||
|
||||
jest.mock('app/mattermost', () => ({
|
||||
app: {
|
||||
setAppCredentials: () => jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
const mockStore = configureStore([thunk]);
|
||||
|
||||
describe('Actions.Views.Login', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue