Created
September 21, 2016 16:53
-
-
Save johnthepink/2d429f7ae3b2ffbcd4a207f184c2f652 to your computer and use it in GitHub Desktop.
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
function* login() { | |
const currentState = yield select(); | |
const { data } = currentState.accounts; | |
if (data.email && data.password) { | |
const { email, password } = data; | |
// set the UI to show the loading screen | |
yield put(actions.loading()); | |
try { | |
// make the call to try and login | |
const isAuthorized = yield cps(accounts.login, email, password); | |
// this should always be true shouldn't it? | |
if (isAuthorized) { | |
// return Meteor login to parent saga | |
yield cps(Meteor.loginWithPassword, email, password); | |
if (isAuthorized) { | |
return { result: isAuthorized }; | |
} | |
return { error: new Meteor.Error("An unkown error occured") }; | |
} | |
} catch (error) { | |
return { error }; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment