Advertisement
Guest User

Untitled

a guest
Aug 29th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. angular.module('starter.controllers')
  2. .controller('LoginCtrl', function($scope, hasura, $ionicPopup) {
  3. $scope.loginData = {
  4. username: '',
  5. password: ''
  6. };
  7. $scope.doLogin = function() {
  8. hasura.setUsername($scope.loginData.username);
  9. hasura.auth.login($scope.loginData.password, function(success) {
  10. console.log('login success');
  11. console.log(hasura.user);
  12. $ionicPopup.alert({
  13. title: 'Success',
  14. template: 'Login success'
  15. });
  16. $scope.$apply();
  17. // execute code after login
  18. }, function(error){
  19. console.log('login failed');
  20. console.log(error);
  21. $ionicPopup.alert({
  22. title: 'Error',
  23. template: 'Login failed'
  24. });
  25. // handle login error
  26. });
  27. };
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement