diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 000000000..45ed82001
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,66 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Iniciar",
+ "type": "node",
+ "request": "launch",
+ "program": "${workspaceRoot}/app.js",
+ "stopOnEntry": false,
+ "args": [],
+ "cwd": "${workspaceRoot}",
+ "preLaunchTask": null,
+ "runtimeExecutable": null,
+ "runtimeArgs": [
+ "--nolazy"
+ ],
+ "env": {
+ "NODE_ENV": "development"
+ },
+ "console": "internalConsole",
+ "sourceMaps": false,
+ "outFiles": []
+ },
+ {
+ "name": "Asociar",
+ "type": "node",
+ "request": "attach",
+ "port": 5858,
+ "address": "localhost",
+ "restart": false,
+ "sourceMaps": false,
+ "outFiles": [],
+ "localRoot": "${workspaceRoot}",
+ "remoteRoot": null
+ },
+ {
+ "name": "Asociar al proceso",
+ "type": "node",
+ "request": "attach",
+ "processId": "${command.PickProcess}",
+ "port": 5858,
+ "sourceMaps": false,
+ "outFiles": []
+ },
+ {
+ "name": "Iniciar node-server",
+ "type": "node",
+ "request": "launch",
+ "program": "${workspaceRoot}\\@salix-services\\login\\server\\server.js",
+ "stopOnEntry": false,
+ "args": [],
+ "cwd": "${workspaceRoot}",
+ "preLaunchTask": null,
+ "runtimeExecutable": null,
+ "runtimeArgs": [
+ "--nolazy"
+ ],
+ "env": {
+ "NODE_ENV": "development"
+ },
+ "console": "internalConsole",
+ "sourceMaps": false,
+ "outFiles": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/@salix-services/login/client/index.ejs b/@salix-services/login/client/index.ejs
new file mode 100644
index 000000000..6ccf86076
--- /dev/null
+++ b/@salix-services/login/client/index.ejs
@@ -0,0 +1,6 @@
+
+
+
prueba
+
+
+
diff --git a/@salix-services/login/server/boot/createmodel.js b/@salix-services/login/server/boot/createmodel.js
new file mode 100644
index 000000000..e2b9f58ff
--- /dev/null
+++ b/@salix-services/login/server/boot/createmodel.js
@@ -0,0 +1,10 @@
+module.exports = function(app) {
+ var User = app.models.User;
+ console.log(app.models.AccessToken);
+ User.create ({
+ email: 'admin@admin.com',
+ password: '1234'
+ }, function (err, user) {
+ console.log ('User created!');
+ });
+};
\ No newline at end of file
diff --git a/@salix-services/login/server/boot/root.js b/@salix-services/login/server/boot/root.js
index 6135b37d7..cc31a40a4 100644
--- a/@salix-services/login/server/boot/root.js
+++ b/@salix-services/login/server/boot/root.js
@@ -3,9 +3,11 @@
module.exports = function(server) {
// Install a `/` route that returns server status
var router = server.loopback.Router();
+
router.get('/status', server.loopback.status());
router.get(['/'],function(req,res){
- res.send("Hello");
+ res.send('hello');
});
+
server.use(router);
};
diff --git a/@salix-services/login/server/boot/routes.js b/@salix-services/login/server/boot/routes.js
new file mode 100644
index 000000000..b225affa0
--- /dev/null
+++ b/@salix-services/login/server/boot/routes.js
@@ -0,0 +1,27 @@
+module.exports = function(app) {
+ var User = app.models.User;
+ app.get('/login',(req,res)=>{
+ res.render('index.ejs',{});
+ });
+
+ app.post('/login', function(req, res) {
+ User.login({
+ email: req.body.email,
+ password: req.body.password
+ }, 'user', function(err, token) {
+ if (err) {
+ res.send(JSON.stringify({
+ title: 'Login failed',
+ content: err,
+ redirectTo: '/',
+ redirectToLinkText: 'Try again'
+ }));
+ } else {
+ res.send(JSON.stringify({
+ email: req.body.email,
+ accessToken: token.id
+ }));
+ }
+ });
+ });
+};
diff --git a/@salix-services/login/server/datasources.json b/@salix-services/login/server/datasources.json
index 0967ef424..fdb36285e 100644
--- a/@salix-services/login/server/datasources.json
+++ b/@salix-services/login/server/datasources.json
@@ -1 +1,9 @@
-{}
+{
+
+"db": {
+ "name": "db",
+ "connector": "memory",
+ "file": "myToken.json"
+ }
+
+}
diff --git a/@salix-services/login/server/middleware.json b/@salix-services/login/server/middleware.json
index fbfff8165..4bf8fed88 100644
--- a/@salix-services/login/server/middleware.json
+++ b/@salix-services/login/server/middleware.json
@@ -6,7 +6,7 @@
"compression": {},
"cors": {
"params": {
- "origin": true,
+ "origin": "*",
"credentials": true,
"maxAge": 86400
}
diff --git a/@salix-services/login/server/model-config.json b/@salix-services/login/server/model-config.json
index 56f6800af..cd7a2d855 100644
--- a/@salix-services/login/server/model-config.json
+++ b/@salix-services/login/server/model-config.json
@@ -12,5 +12,14 @@
"../common/mixins",
"./mixins"
]
+ },
+ "User": {
+ "dataSource": "db",
+ "public": false
+ },
+ "AccessToken": {
+ "dataSource": "db",
+ "public": false,
+ "strict": true
}
-}
+}
\ No newline at end of file
diff --git a/@salix-services/login/server/server.js b/@salix-services/login/server/server.js
index ef738abce..e5fc38426 100644
--- a/@salix-services/login/server/server.js
+++ b/@salix-services/login/server/server.js
@@ -2,15 +2,25 @@
var loopback = require('loopback');
var boot = require('loopback-boot');
-
+var express=require('express');
+var path = require('path');
var app = module.exports = loopback();
+
+// modificado
+app.set('view engine', 'ejs');
+app.set('views',path.join(__dirname,'../client'));
+app.use(loopback.static(path.resolve(__dirname, '../client')));
+// fin
+
+
+
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
- console.log('Web server listening at: %s', baseUrl);
+ console.log('Web server LOGIN listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
diff --git a/@salix/login/src/login/login.js b/@salix/login/src/login/login.js
index bb8616771..f6ef26324 100644
--- a/@salix/login/src/login/login.js
+++ b/@salix/login/src/login/login.js
@@ -60,4 +60,9 @@ export const COMPONENT =
};
module.component('vnLogin', COMPONENT);
+module.config(['$httpProvider', function($httpProvider) {
+ $httpProvider.defaults.useXDomain = true;
+ delete $httpProvider.defaults.headers.common['X-Requested-With'];
+ }
+]);