-
-
Save sushmasonus/f61aa093d68ca6ae0d6594fb509e4e94 to your computer and use it in GitHub Desktop.
This file contains 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
angular.module('app', ['ngRoute']) | |
.config(function($httpProvider,$routeProvider) { | |
$routeProvider | |
.when('/login', { | |
templateUrl: 'index.html', | |
controller: 'postserviceCtrl' | |
}) | |
.when('/register', { | |
templateUrl: 'sign-up-user-account.html', | |
controller: 'postregisterCtrl' | |
}) | |
.otherwise({ | |
redirectTo: '/login' | |
}); | |
$httpProvider.interceptors.push(function($q, $rootScope, ConfigService) { | |
return { | |
request: function(config) { | |
ConfigService.getHttpUrl(config); | |
ConfigService.setApiKey(config); | |
return config; | |
} | |
} | |
}) | |
}) | |
.factory('ConfigService', function() { | |
var base_url = "http://localhost:80/Lumen-5.2-Swagger-2.0/Trunk/public/v1"; | |
var App_key = "123"; | |
return { | |
getHttpUrl: function(config) { | |
config.url = base_url + config.url; | |
}, | |
setApiKey: function(config) { | |
config.headers['Api_key'] = App_key; | |
config.headers['session_token'] = '$2y$10$eqCudTg2xrJVpydokr.L1eXFGaEm1XgX8DnO.YyDw4aCh.SRPirqO'; | |
// config.headers['Access-Control-Allow-Origin'] = '*'; | |
// config.headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS, PUT'; | |
// config.headers['Access'] = '*'; | |
// config.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; | |
} | |
}; | |
}) | |
//Login | |
.controller('postserviceCtrl', function($scope, $http) { | |
$scope.email = null; | |
$scope.password = null; | |
$scope.postdata = function(email, password) { | |
var data = { | |
email: email, | |
password: password, | |
login_type:1 | |
}; | |
console.log(data); | |
//Call the services | |
$http.post('/login', JSON.stringify(data)).success(function(data, status) { | |
$scope.msg = "Post Data Submitted Successfully!"; | |
console.log(data); | |
}).error(function(data, status) { | |
$scope.msg = "Invalid Login!"; | |
}); | |
}; | |
}); | |
//Registration | |
.controller('postregisterCtrl', function($scope, $http) { | |
$scope.first_name = null; | |
$scope.last_name = null; | |
$scope.email = null; | |
$scope.password = null; | |
$scope.gender = null; | |
$scope.dob = null; | |
$scope.postdata = function(email, password) { | |
var data = { | |
first_name:first_name, | |
last_name:last_name, | |
email: email, | |
password: password, | |
gender:gender, | |
dob:dob, | |
device_id:1, | |
fb_token:nmm, | |
reg_type:1 | |
}; | |
console.log(data); | |
//Call the services | |
$http.post('/register', JSON.stringify(data)).success(function(data, status) { | |
$scope.msg = "Post Data Submitted Successfully!"; | |
console.log(data); | |
}).error(function(data, status) { | |
$scope.msg = "Invalid Register!"; | |
}); | |
}; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment