Advertisement
Guest User

Untitled

a guest
Jan 30th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. /**
  2. * Created by urunzl on 24.1.2017.
  3. */
  4. import Dispatcher from '../dispatcher/Dispatcher';
  5. import loginConstants from '../constants/loginConstants';
  6. import loginStore from '../stores/loginStore';
  7. import messageConstants from '../constants/messageConstants';
  8.  
  9.  
  10. var loginActions = {
  11. login: function(password) {
  12. let user = null;
  13. const users = loginStore.getUsers();
  14. Object.keys(users).map(function(item){
  15. let model = users[item];
  16. if(model.password === password)
  17. user = model;
  18. });
  19. if (!user){
  20. Dispatcher.handleAction({
  21. actionType: messageConstants.SHOW_MESSAGE,
  22. data: "BAD PASSWORD",
  23. error: true
  24. });
  25. }else{
  26. Dispatcher.handleAction({
  27. actionType: loginConstants.LOGIN,
  28. data: user
  29. });
  30. }
  31. },
  32. logout: function(){
  33. console.log('logOut');
  34. Dispatcher.handleAction({
  35. actionType: loginConstants.LOGOUT
  36. })
  37. }
  38. };
  39.  
  40. export default loginActions;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement