Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flux action with login
var client = require("shared/client");
module.exports = function(context, payload, done) {
if (payload.login === undefined) {
throw new Error("Login must be defined");
}
if (payload.password === undefined) {
throw new Error("Password must be defined");
}
context.dispatch("event:LoginStarted");
var login = payload.login;
var password = payload.password;
client.login(login, password, function(err, res) {
if (err !== undefined) {
context.dispatch("event:LoginFailed", err);
done();
} else {
context.dispatch("event:LoginSucceeded", res);
done();
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment