Add an action to derive the encryption key.

master
Tom Hacohen 7 years ago
parent 232ea823d0
commit 2608a354ea

@ -31,6 +31,13 @@ export const { fetchCredentials, logout } = createActions({
LOGOUT: () => undefined, LOGOUT: () => undefined,
}); });
// FIXME: This is duplicating behaviour from the fetchCredentials above
export const { deriveKey } = createActions({
DERIVE_KEY: (username: string, encryptionPassword: string) => {
return EteSync.deriveKey(username, encryptionPassword);
},
});
export const { fetchJournals } = createActions({ export const { fetchJournals } = createActions({
FETCH_JOURNALS: (etesync: CredentialsData) => { FETCH_JOURNALS: (etesync: CredentialsData) => {
const creds = etesync.credentials; const creds = etesync.credentials;

@ -90,6 +90,9 @@ const encryptionKeyReducer = handleActions(
return {key: action.payload.encryptionKey}; return {key: action.payload.encryptionKey};
} }
}, },
[actions.deriveKey.toString()]: (state: {key: string | null}, action: any) => (
{key: action.payload}
),
[actions.logout.toString()]: (state: {key: string | null}, action: any) => { [actions.logout.toString()]: (state: {key: string | null}, action: any) => {
return {out: true, key: null}; return {out: true, key: null};
}, },

Loading…
Cancel
Save