#981 Login fixes
This commit is contained in:
parent
2a447c2107
commit
71af7f6d0e
|
@ -41,7 +41,7 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t
|
||||||
|
|
||||||
if (validations) {
|
if (validations) {
|
||||||
promises.push(new Promise(resolve => {
|
promises.push(new Promise(resolve => {
|
||||||
$http.get(`/${moduleName}/validations`).then(
|
$http.get(`/${moduleName}/api/modelInfo`).then(
|
||||||
json => this.onValidationsReady(json, resolve),
|
json => this.onValidationsReady(json, resolve),
|
||||||
() => resolve()
|
() => resolve()
|
||||||
);
|
);
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default class Auth {
|
||||||
logout() {
|
logout() {
|
||||||
let promise = this.$http.post('/api/Accounts/logout', null, {
|
let promise = this.$http.post('/api/Accounts/logout', null, {
|
||||||
headers: {Authorization: this.vnToken.token}
|
headers: {Authorization: this.vnToken.token}
|
||||||
});
|
}).catch(() => {});
|
||||||
|
|
||||||
this.vnToken.unset();
|
this.vnToken.unset();
|
||||||
this.loggedIn = false;
|
this.loggedIn = false;
|
||||||
|
|
|
@ -2,5 +2,5 @@ Invalid login: Invalid login, remember that distinction is made between uppercas
|
||||||
Could not contact the server: Could not contact the server, make sure you have a connection to the network
|
Could not contact the server: Could not contact the server, make sure you have a connection to the network
|
||||||
Please enter your username: Please enter your username
|
Please enter your username: Please enter your username
|
||||||
It seems that the server has fall down: It seems that the server has fall down, wait a few minutes and try again
|
It seems that the server has fall down: It seems that the server has fall down, wait a few minutes and try again
|
||||||
Your session has expired: Your session has expired
|
Session has expired: Your session has expired, please login again
|
||||||
Access denied: Access denied
|
Access denied: Access denied
|
|
@ -2,5 +2,5 @@ Invalid login: Usuario o contraseña incorrectos, recuerda que se hace distinci
|
||||||
Could not contact the server: No se ha podido contactar con el servidor, asegurate de que dispones de conexión con la red
|
Could not contact the server: No se ha podido contactar con el servidor, asegurate de que dispones de conexión con la red
|
||||||
Please enter your username: Por favor introduce tu nombre de usuario
|
Please enter your username: Por favor introduce tu nombre de usuario
|
||||||
It seems that the server has fall down: Parece que el servidor se ha caído, espera unos minutos e inténtalo de nuevo
|
It seems that the server has fall down: Parece que el servidor se ha caído, espera unos minutos e inténtalo de nuevo
|
||||||
Your session has expired: Tu sesión ha expirado
|
Session has expired: Tu sesión ha expirado, por favor vuelve a iniciar sesión
|
||||||
Access denied: Acción no permitida
|
Access denied: Acción no permitida
|
|
@ -1,7 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html ng-app="salix">
|
<html ng-app="salix">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=no"/>
|
||||||
|
<meta name="mobile-web-app-capable" content="yes"/>
|
||||||
<title vn-title translate></title>
|
<title vn-title translate></title>
|
||||||
<script src="/acl"></script>
|
<script src="/acl"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -83,7 +83,7 @@ function $exceptionHandler(vnApp, $window, $state, $injector) {
|
||||||
switch (exception.status) {
|
switch (exception.status) {
|
||||||
case 401:
|
case 401:
|
||||||
if ($state.current.name != 'login') {
|
if ($state.current.name != 'login') {
|
||||||
messageT = 'Your session has expired';
|
messageT = 'Session has expired';
|
||||||
let params = {continue: $window.location.hash};
|
let params = {continue: $window.location.hash};
|
||||||
$state.go('login', params);
|
$state.go('login', params);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
<html ng-app="salix">
|
<html ng-app="salix">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=no"/>
|
||||||
|
<meta name="mobile-web-app-capable" content="yes"/>
|
||||||
<title vn-title translate></title>
|
<title vn-title translate></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1,4 +1,63 @@
|
||||||
module.exports = function(app) {
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('modelInfo', {
|
||||||
|
description: 'Gets all models information',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'ctx',
|
||||||
|
type: 'Object',
|
||||||
|
http: {source: 'context'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: 'Object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/modelInfo`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.modelInfo = async function(ctx) {
|
||||||
|
let json = {};
|
||||||
|
let models = Self.app.models;
|
||||||
|
|
||||||
|
for (let modelName in models) {
|
||||||
|
let model = models[modelName];
|
||||||
|
let validations = model.validations;
|
||||||
|
let jsonValidations = {};
|
||||||
|
|
||||||
|
for (let fieldName in validations) {
|
||||||
|
let jsonField = [];
|
||||||
|
|
||||||
|
for (let validation of validations[fieldName]) {
|
||||||
|
let options = validation.options;
|
||||||
|
|
||||||
|
if ((options && options.async) ||
|
||||||
|
(validation.validation == 'custom' && !validation.isExportable))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
let validationCp = Object.assign({}, validation);
|
||||||
|
|
||||||
|
if (validationCp.message)
|
||||||
|
validationCp.message = ctx.req.__(validationCp.message);
|
||||||
|
|
||||||
|
jsonField.push(toJson(validationCp));
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonValidations[fieldName] = jsonField;
|
||||||
|
}
|
||||||
|
|
||||||
|
json[modelName] = {
|
||||||
|
properties: model.definition.rawProperties,
|
||||||
|
validations: jsonValidations
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return json;
|
||||||
|
};
|
||||||
|
|
||||||
function toJson(object) {
|
function toJson(object) {
|
||||||
let json = {};
|
let json = {};
|
||||||
|
|
||||||
|
@ -20,44 +79,4 @@ module.exports = function(app) {
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get('/validations', function(req, res) {
|
|
||||||
let json = {};
|
|
||||||
let models = app.models;
|
|
||||||
|
|
||||||
for (let modelName in models) {
|
|
||||||
let model = models[modelName];
|
|
||||||
let validations = model.validations;
|
|
||||||
let jsonValidations = {};
|
|
||||||
|
|
||||||
for (let fieldName in validations) {
|
|
||||||
let jsonField = [];
|
|
||||||
|
|
||||||
for (let validation of validations[fieldName]) {
|
|
||||||
let options = validation.options;
|
|
||||||
|
|
||||||
if ((options && options.async) ||
|
|
||||||
(validation.validation == 'custom' && !validation.isExportable))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
let validationCp = Object.assign({}, validation);
|
|
||||||
|
|
||||||
if (validationCp.message)
|
|
||||||
validationCp.message = req.__(validationCp.message);
|
|
||||||
|
|
||||||
jsonField.push(toJson(validationCp));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonValidations[fieldName] = jsonField;
|
|
||||||
}
|
|
||||||
|
|
||||||
json[modelName] = {
|
|
||||||
properties: model.definition.rawProperties,
|
|
||||||
validations: jsonValidations
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
res.set('Content-Type', 'application/json');
|
|
||||||
res.send(JSON.stringify(json));
|
|
||||||
});
|
|
||||||
};
|
};
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
module.exports = function(Self) {
|
||||||
|
require('../methods/schema/model-info')(Self);
|
||||||
|
};
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"name": "Schema",
|
||||||
|
"base": "PersistedModel",
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"property": "validations",
|
||||||
|
"accessType": "EXECUTE",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -7,4 +7,12 @@ module.exports = function(app) {
|
||||||
version: bootTimestamp
|
version: bootTimestamp
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// FIXME: Fix until the original can be used
|
||||||
|
app.get('/api/modelInfo', function(req, res) {
|
||||||
|
app.models.Schema.modelInfo({req}).then(json => {
|
||||||
|
res.set('Content-Type', 'application/json');
|
||||||
|
res.send(JSON.stringify(json));
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,5 +43,8 @@
|
||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"Schema": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue