Update routes, mongoose schema and web flow
This commit is contained in:
86
app/partials/login/login.controllers.js
Normal file
86
app/partials/login/login.controllers.js
Normal file
@@ -0,0 +1,86 @@
|
||||
(function(){
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('app.login')
|
||||
.controller('loginCtrl', loginCtrl)
|
||||
|
||||
loginCtrl.$inject = ['$rootScope', '$scope', '$location'];
|
||||
function loginCtrl($rootScope, $scope, $location){
|
||||
/*var vm = this;
|
||||
vm.user = user;
|
||||
vm.submitted = false;
|
||||
vm.mayorque = false;
|
||||
$rootScope.items = "";
|
||||
$rootScope.mensaje = "";
|
||||
vm.submit = function() {
|
||||
if (vm.data_input_form.$valid){
|
||||
vm.pkg = {
|
||||
"Nickname": vm.user.Nickname,
|
||||
"Password": $rootScope.password
|
||||
};
|
||||
|
||||
$rootScope.mensaje = "";
|
||||
$rootScope.bcancel = false;
|
||||
$scope.modalInstance = $modal.open({
|
||||
animation: $rootScope.animationsEnabled,
|
||||
templateUrl: 'LoginModal.html',
|
||||
scope: $scope,
|
||||
size: 'sm',
|
||||
resolve: {
|
||||
items: function () {
|
||||
return $rootScope.items;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Login.save(vm.pkg,
|
||||
function(data){
|
||||
if(data.Data._value != null){
|
||||
$rootScope.actOk = true;
|
||||
$rootScope.urlLo = 'listarProfesor';
|
||||
$rootScope.bcancel = false;
|
||||
|
||||
}else{
|
||||
$rootScope.bcancel = true;
|
||||
$rootScope.mensaje = data.Data._error;
|
||||
}
|
||||
},
|
||||
function(data){
|
||||
verificar = data.Data;
|
||||
if(verificar){
|
||||
alert("no existe el usuario");
|
||||
}
|
||||
})
|
||||
GetRol.get({id:vm.user.Nickname},
|
||||
function(data){
|
||||
$rootScope.role = data.Data;
|
||||
},
|
||||
function(){
|
||||
|
||||
});
|
||||
|
||||
}else{
|
||||
vm.submitted = true;
|
||||
}
|
||||
}
|
||||
|
||||
$rootScope.open = function($event) {
|
||||
$event.preventDefault();
|
||||
$event.stopPropagation();
|
||||
$rootScope.opened = true;
|
||||
};
|
||||
|
||||
$scope.ok = function (urlLo) {
|
||||
$location.url(urlLo);
|
||||
$scope.modalInstance.dismiss('cancel');
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
$scope.modalInstance.dismiss('cancel');
|
||||
};
|
||||
|
||||
return vm; */
|
||||
};
|
||||
|
||||
})();
|
||||
65
app/partials/login/login.html
Normal file
65
app/partials/login/login.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<form name="vm.data_input_form" role="form" novalidate ng-submit="vm.submit()">
|
||||
<div class="row clearfix">
|
||||
<div class="col-md-10 column well">
|
||||
<h4 style="text-align: center">Ingrese sus Datos</h4>
|
||||
<div class="row" >
|
||||
<div class="col-md-4 column">
|
||||
</div>
|
||||
<div class="col-md-4 column">
|
||||
<label for="nickname">Cedula de Identidad del Profesor</label>
|
||||
<input type="text" class="form-control" id="nickname" name="nickname" ng-model="vm.user.Nickname" required/>
|
||||
<div class="error" ng-show="vm.submitted && vm.data_input_form.nickname.$invalid">
|
||||
<small class="error" ng-show="vm.data_input_form.nickname.$error.required">
|
||||
{{'TAG_NICK_NAME_ERROR'}}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix"><div class="col-md-12 column"><br><br></div></div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 column">
|
||||
</div>
|
||||
<div class="col-md-4 column">
|
||||
<label for="password">Contraseña</label>
|
||||
<input type="password" class="form-control" id="password" name="password" ng-model="vm.user.Password" maxlength="8" required/>
|
||||
<div ng-show=false> {{ vm.password = vm.user.Password }}</div>
|
||||
<div class="error" ng-show="vm.submitted && vm.data_input_form.password.$invalid">
|
||||
<small class="error" ng-show="vm.data_input_form.password.$error.required">
|
||||
{{'TAG_PASSWORD_ERROR'}}
|
||||
</small>
|
||||
</div>
|
||||
<div ng-show=false>{{getHash(vm.password)}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end column -->
|
||||
</div> <!-- end row -->
|
||||
|
||||
<div class="row clearfix">
|
||||
<div class="col-md-2 column">
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
<p class="input-group">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" id="submit" class="btn-primary btn" >Ingresar</button>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
<script type="text/ng-template" id="myModalContentLogin.html">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Censys</h3>
|
||||
</div>
|
||||
<div style="text-align: center" class="modal-body">
|
||||
<div ng-show="loadingLogin" style="text-align: center" class="loading"><img src="img/login-loading.gif"></div>
|
||||
{{ mensaje }}
|
||||
<div ng-show=false> {{ index }}</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div ng-show=false > {{ okLogin(actOk, urlLo) }}</div>
|
||||
<button class="btn btn-warning" ng-show="bcancel" type="button" ng-click="cancel()">Cancel</button>
|
||||
</div>
|
||||
</script>
|
||||
</form>
|
||||
|
||||
30
app/partials/login/login.module.js
Normal file
30
app/partials/login/login.module.js
Normal file
@@ -0,0 +1,30 @@
|
||||
(function(){
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module("app.login", ['ui.router', 'ui.bootstrap'])
|
||||
.run(addStateToScope)
|
||||
.config(getRoutes);
|
||||
|
||||
addStateToScope.$inject = ['$rootScope', '$state', '$stateParams'];
|
||||
function addStateToScope($rootScope, $state, $stateParams){
|
||||
$rootScope.$state = $state;
|
||||
$rootScope.$stateParams = $stateParams;
|
||||
};
|
||||
|
||||
getRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
|
||||
function getRoutes($stateProvider, $urlRouterProvider){
|
||||
$urlRouterProvider.otherwise('/');
|
||||
$stateProvider
|
||||
.state('root', {
|
||||
url: '',
|
||||
views: {
|
||||
content: {
|
||||
templateUrl: 'partials/login/login.html',
|
||||
controller: 'loginCtrl',
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
})();
|
||||
49
app/partials/login/login.services.js
Normal file
49
app/partials/login/login.services.js
Normal file
@@ -0,0 +1,49 @@
|
||||
(function(){
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('app.login')
|
||||
.factory('Login', Login)
|
||||
.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');
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user