Errores solucionados

This commit is contained in:
Juan Ferrer Toribio 2017-06-02 15:39:16 +02:00
parent 02d0e167a0
commit 8cd312e145
2 changed files with 7 additions and 5 deletions

View File

@ -64,7 +64,7 @@ function vnAppInterceptor($q, $rootScope, $window, logger, $translate, $cookies)
let location = $window.location;
let continueUrl = location.pathname + location.search + location.hash;
continueUrl = encodeURIComponent(continueUrl);
$window.location = `/auth?continue=${continueUrl}`;
$window.location = `/auth/?apiKey=salix&continue=${continueUrl}`;
}
logger.showError(error);

View File

@ -1,4 +1,6 @@
module.exports = function (app) {
let models = app.models;
app.get('/', function (req, res) {
let token = req.cookies.vnToken;
validateToken(token, function(isValid) {
@ -36,13 +38,13 @@ module.exports = function (app) {
app.get('/logout', function (req, res) {
let token = req.cookies.vnToken;
app.models.User.logout(token, function(err) {
models.User.logout(token, function() {
redirectToAuth(res);
});
});
function validateToken(tokenId, cb) {
app.models.AccessToken.findById(tokenId, function(err, token) {
models.AccessToken.findById(tokenId, function(err, token) {
if (token) {
token.validate (function (err, isValid) {
cb(isValid === true, token);
@ -67,7 +69,7 @@ module.exports = function (app) {
}
}]
};
app.models.RoleMapping.find(query, function(err, roles){
models.RoleMapping.find(query, function(_, roles){
if(roles){
var acl = {
userProfile: {},
@ -79,7 +81,7 @@ module.exports = function (app) {
acl.roles[rol.name] = true;
}
});
app.models.User.findById(token.userId, function(_, userProfile){
models.User.findById(token.userId, function(_, userProfile){
//acl.userProfile = userProfile;
acl.userProfile.id = userProfile.id;
acl.userProfile.username = userProfile.username;