Guest User

Untitled

a guest
Jan 24th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Pq.Statechart = SC.Statechart.create({
  2. rootState: SC.State.design({
  3. initialSubstate: 'loggedOut',
  4.  
  5. loggedOut: SC.State.design({
  6. enterState: function() {
  7. Pq.getPath('loginPage.mainPane').append();
  8. },
  9. exitState: function(){
  10. Pq.getPath('loginPage.mainPane').remove();
  11. },
  12. authenticate: function(){
  13. var userName = Pq.getPath('loginController.userName');
  14. var password = Pq.getPath('loginController.password');
  15. SC.Request.postUrl('/auth/', {login: userName, password: password}).notify(this, 'didCompleteAuthentication').json().send();
  16. },
  17. didCompleteAuthentication: function(response){
  18. if (SC.ok(response)) {
  19. this.gotoState('loggedIn');
  20. } else {
  21. SC.AlertPane.error({message:'Неверные реквизиты доступа!',description:'Возможно, вы допустили опечатку. Попробуйте снова.',caption:'Ошибка авторизации'});
  22. }
  23. }
  24. }),
  25.  
  26. loggedIn: SC.State.design({
  27. enterState: function() {
  28. Pq.getPath('mainPage.mainPane').append();
  29. }
  30. })
  31. }
Add Comment
Please, Sign In to add comment