Last active
January 27, 2019 08:53
-
-
Save zulucoda/c6a18e10f6c5e441137493769aad73ab to your computer and use it in GitHub Desktop.
Before Refactor - user login proccess
This file contains hidden or 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
/** | |
* Before Refactor - user login proccess | |
* @see https://blog.mfbproject.co.za | |
*/ | |
export function* userLoginSaga() { | |
// 1. get the username and password from state. | |
const { username, password } = yield select(getLoginFormState); | |
// 2. call login API endpoint with the username and password | |
const loginService = new LoginService(); | |
const loginResponse = yield call([loginService, get, username, password]); | |
// 3. set auth token in store | |
yield put(LoginActions.setAuthToken(loginResponse.token)); | |
//4. remove the username and password from store | |
yield put(LoginActions.clearLogin()); | |
//5. call settings API endpoint with authorisation token | |
const settingsService = new SettingsService(); | |
const setingsResponse = yield call([settingsService, get]); | |
//6. set the user settings in store | |
yield put(SettingsActions.onReceiveSettings(setingsResponse)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment