Initial commit

This commit is contained in:
Reynaldo Reyes
2016-02-29 00:49:18 -04:30
commit 90d22e3405
67 changed files with 4025 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
(function(){
'use strict';
angular
.module('app.login')
.factory('Login', Login)
.factory('Rol', Rol)
.factory('GetRol', GetRol)
.factory('hash', hash)
.value('algoritmo','SHA-1')
.value('user',{})
.value('id',{})
Login.$inject = ['$resource','$rootScope'];
function Login($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/api/VerifyUser');
};
Rol.$inject = ['$resource','$rootScope'];
function Rol($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/api/Rol');
};
GetRol.$inject = ['$resource','$rootScope'];
function GetRol($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/api/User/:id');
};
hash.$inject = ['algoritmo'];
function hash(algoritmo){
var hashFunction;
if (algoritmo==="MD5") {
hashFunction=CryptoJS.MD5;
} else if (algoritmo==="SHA-1") {
hashFunction=CryptoJS.SHA1;
} else if (algoritmo==="SHA-2-256") {
hashFunction=CryptoJS.SHA256;
} else if (algoritmo==="SHA-2-512") {
hashFunction=CryptoJS.SHA512;
} else {
throw Error("El tipo de algoritmo no es válido:"+algoritmo);
}
var hash=function(message) {
var objHashResult=hashFunction(message);
var strHashResult=objHashResult.toString(CryptoJS.enc.Base64);
return strHashResult;
}
return hash;
};
})();