Created
December 10, 2015 15:13
-
-
Save kolexinfos/a1a7cf0043c8f6792b6a 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
| $scope.$on('$ionicView.enter', function(){ | |
| vm.errorMessage = $stateParams.errorMessage; | |
| //if persisted User object exist then go to home page, means user has logged in before | |
| if(PersistDataService.getObject(user) != undefined){ | |
| $state.go('home') | |
| } | |
| vm.doLogin = function(e) { | |
| //Check if mobile number exist on the database, this returns SECURITY Question, TOKEN and Password(ignored not used) | |
| AirtimeService | |
| .validate(vm.phone) | |
| .then(function(response){ | |
| if(response != "ERROR"){ | |
| //means response contains set of pipe delimited string --> security|code(TOKEN)|password | |
| //use the security which is the Security Question to present a from to do extra authentication | |
| //vm.token = get TOKEN from the string | |
| //Present a security Question and answer view to authenticate the user and use the getSecurityQuestion in UserService to see if the | |
| //answer provided is correct | |
| AuthService | |
| .doLoginWithQuestion | |
| .then(function(response){ | |
| if(response === 8001){ | |
| //set login data | |
| AuthService.setLoginData({ | |
| msisdn:vm.phone, | |
| password:vm.password, | |
| autcode: vm.autcode, //get the autcode which is IMEI from device or from a randomly generated and persisted on device user | |
| device: vm.device, //get device name using cordova | |
| token:vm.token, //get token from the reponse object | |
| version: '4.0' | |
| }); | |
| $state.go('loading'); | |
| } | |
| else{ | |
| //show the user that security question is wrong | |
| } | |
| }) | |
| } | |
| else{ | |
| //show error message and go to register | |
| $state.go('register') | |
| } | |
| }) | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment