|
@@ -8,6 +8,8 @@ import {
|
|
|
LOGIN_USER
|
|
LOGIN_USER
|
|
|
} from './types';
|
|
} from './types';
|
|
|
|
|
|
|
|
|
|
+import { saveLogin } from './LocalStorageActions';
|
|
|
|
|
+
|
|
|
export const emailChanged = (text) => {
|
|
export const emailChanged = (text) => {
|
|
|
return {
|
|
return {
|
|
|
type: EMAIL_CHANGED,
|
|
type: EMAIL_CHANGED,
|
|
@@ -23,11 +25,12 @@ export const passwordChanged = (text) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export const loginUser = ({ email, password }) => {
|
|
export const loginUser = ({ email, password }) => {
|
|
|
- return (dispatch) => {
|
|
|
|
|
|
|
+ return (dispatch) => {
|
|
|
|
|
+ const SHA256 = require('sha256');
|
|
|
dispatch({ type: LOGIN_USER });
|
|
dispatch({ type: LOGIN_USER });
|
|
|
- post('login.php', { user: email, pass: password })
|
|
|
|
|
|
|
+ post('login.php', { user: email, pass: SHA256(password) })
|
|
|
.then(
|
|
.then(
|
|
|
- (response) => loginUserSuccess(dispatch, response)
|
|
|
|
|
|
|
+ (response) => loginUserSuccess(dispatch, response, password)
|
|
|
).catch(
|
|
).catch(
|
|
|
(error) => loginUserFail(dispatch, error)
|
|
(error) => loginUserFail(dispatch, error)
|
|
|
);
|
|
);
|
|
@@ -39,10 +42,11 @@ const loginUserFail = (dispatch, error) => {
|
|
|
dispatch({ type: LOGIN_USER_FAIL, payload: error });
|
|
dispatch({ type: LOGIN_USER_FAIL, payload: error });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const loginUserSuccess = (dispatch, user) => {
|
|
|
|
|
|
|
+const loginUserSuccess = (dispatch, user, password='') => {
|
|
|
dispatch({
|
|
dispatch({
|
|
|
type: LOGIN_USER_SUCCESS,
|
|
type: LOGIN_USER_SUCCESS,
|
|
|
payload: user
|
|
payload: user
|
|
|
});
|
|
});
|
|
|
- Actions.Menu();
|
|
|
|
|
|
|
+ saveLogin({ user: user.email, password: password })
|
|
|
|
|
+ Actions.Menu({type: 'reset'});
|
|
|
};
|
|
};
|