github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/build-blockchain-insurance-app-master/web/src/insurance/actions/userMgmtActions.js (about)

     1  'use strict';
     2  
     3  import * as UserMgmtActionType from './userMgmtActionTypes';
     4  import * as Api from '../api';
     5  
     6  export function authenticateUser(user) {
     7    return async dispatch => {
     8      try {
     9        let userAuthenticated = await Api.authenticateUser(user);
    10        if (userAuthenticated) {
    11          dispatch(setUser(user));
    12        } else {
    13          dispatch(setUser(false));
    14        }
    15      } catch (error) {
    16        console.log(error);
    17      }
    18    };
    19  }
    20  
    21  export function setUser(user) {
    22    return {
    23      type: UserMgmtActionType.SET_USER,
    24      user
    25    };
    26  }