<commit_before>'use strict';

angular.module('angWeatherAppApp')
  .controller('LoginCtrl', function ($scope, $http, setting, $cookieStore) {
  	var url = setting.apiurl + "/verify_credentials";
  	$scope.submit = function(){
  		var sendData = {
  			"username": $scope.username,
  			"password": $<PASSWORD>
  		};
  		$http.post(url, sendData)
  		.success(function(data){
  			$cookieStore.put('angWeatherToken', data.token);
  			console.log($cookieStore.get("angWeatherToken"));
  		})
  		.error(function(data) {
        	console.log('Error: ' + data);
      });
  	}
  });<commit_msg>added basic login and redirect services to the application<commit_after>'use strict';

angular.module('angWeatherAppApp')
  .controller('LoginCtrl', function ($scope, $http, setting, $cookieStore, $location) {
  	var url = setting.apiurl + "/verify_credentials";
  	var authorize_url = setting.apiurl + "/authorize_token/";
  	var authorize_token = 'Token ' + $cookieStore.get("angWeatherToken");
  	$http.defaults.headers.common.Authorization = authorize_token;
  	$http.get(authorize_url)
  	.success(function(data){
  		console.log(data);
  		if(data.role == 0){
  			$location.path("/main");
  		} else if(data.role == 1){
  			$location.path("/main");
  		} else if(data.role == 2) {
  			$location.path("/main");
  		}
  	})
  	.error(function(data){
  		console.log(data);
  	});
  	$scope.submit = function(){
  		var sendData = {
  			"username": $scope.username,
  			"password": $<PASSWORD>
  		};
  		$http.post(url, sendData)
  		.success(function(data){
  			$cookieStore.put('angWeatherToken', data.token);
  			$location.path("/main");
  		})
  		.error(function(data) {
        	console.log('Error: ' + data);
      });
  	}
  });
{'fraction_non_alphanumeric': 0.1771132834962622, 'fraction_numerical': 0.0017251293847038527, 'mean_word_length': 3.393939393939394, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6523557', 'n_tokens_mistral': 647, 'n_tokens_neox': 628, 'n_words': 95}