Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tma-backend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Denys Tito Urbano
tma-backend
Commits
db7bae23
Commit
db7bae23
authored
Mar 18, 2024
by
Denys Tito Urbano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parametros cambiados para el login
parent
3e8cac99
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
5 deletions
+62
-5
.DS_Store
.DS_Store
+0
-0
.env
.env
+4
-2
auth.controller.js
controllers/auth.controller.js
+14
-0
auth.db.js
db/auth.db.js
+31
-2
auth.router.js
routes/auth.router.js
+7
-1
auth.service.js
services/auth.service.js
+6
-0
No files found.
.DS_Store
0 → 100644
View file @
db7bae23
File added
.env
View file @
db7bae23
...
@@ -7,8 +7,9 @@ DRIVE_ACCOUNT=materiales@sacooliveros.edu.pe
...
@@ -7,8 +7,9 @@ DRIVE_ACCOUNT=materiales@sacooliveros.edu.pe
DB_POSTGRESQL_SIIAA_HOST=162.0.227.166
DB_POSTGRESQL_SIIAA_HOST=162.0.227.166
DB_POSTGRESQL_SIIAA_PORT=5434
DB_POSTGRESQL_SIIAA_PORT=5434
DB_POSTGRESQL_SIIAA_NAME=db_sis_siiaa_mig
DB_POSTGRESQL_SIIAA_NAME=db_sis_siiaa_mig
DB_POSTGRESQL_SIIAA_USERNAME=usr_
soporte
DB_POSTGRESQL_SIIAA_USERNAME=usr_
trismegisto
DB_POSTGRESQL_SIIAA_PASSWORD=
s@c00504+
DB_POSTGRESQL_SIIAA_PASSWORD=
S@c0+180405$
URL_FACTURACION_ELECTRONICA_SIIAA=https://fichaonline.sacooliveros.edu.pe:8080/FacturacionElectronicaSIIAA/api/v1
URL_FACTURACION_ELECTRONICA_SIIAA=https://fichaonline.sacooliveros.edu.pe:8080/FacturacionElectronicaSIIAA/api/v1
URL_TRISMEGISTO_APIS=https://fichaonline.sacooliveros.edu.pe:8000/trismegisto-apis/api/v1
URL_TRISMEGISTO_APIS=https://fichaonline.sacooliveros.edu.pe:8000/trismegisto-apis/api/v1
URL_SO_API_NOTIFICATION=https://fichaonline.sacooliveros.edu.pe:8000/so-api-notification/poqh/so-api-notification
\ No newline at end of file
controllers/auth.controller.js
View file @
db7bae23
...
@@ -16,6 +16,18 @@ const post_login = async (req, res) => {
...
@@ -16,6 +16,18 @@ const post_login = async (req, res) => {
}
}
};
};
const
post_generar_usuario
=
async
(
req
,
res
)
=>
{
try
{
const
{
tipo_operacion
,
correo
,
perfil
}
=
req
.
body
;
const
salida
=
await
service
.
post_generar_usuario
({
tipo_operacion
,
correo
,
perfil
});
const
{
json
}
=
salida
;
res
.
json
(
json
);
}
catch
(
error
)
{
res
.
status
(
400
).
json
(
error_json
(
error
.
message
));
}
};
const
get_account
=
async
(
req
,
res
)
=>
{
const
get_account
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
{
documento
}
=
req
.
params
;
const
{
documento
}
=
req
.
params
;
...
@@ -30,5 +42,6 @@ const get_account = async (req, res) => {
...
@@ -30,5 +42,6 @@ const get_account = async (req, res) => {
module
.
exports
=
{
module
.
exports
=
{
post_login
,
post_login
,
post_generar_usuario
,
get_account
get_account
};
};
\ No newline at end of file
db/auth.db.js
View file @
db7bae23
const
{
default
:
axios
}
=
require
(
'axios'
);
const
{
encrypt
}
=
require
(
'../helpers/encrypt'
);
const
{
encrypt
}
=
require
(
'../helpers/encrypt'
);
const
connection
=
require
(
'./config'
);
const
connection
=
require
(
'./config'
);
...
@@ -5,17 +6,44 @@ const post_login = async ({ email, password }) => {
...
@@ -5,17 +6,44 @@ const post_login = async ({ email, password }) => {
if
(
password
)
{
if
(
password
)
{
const
password_encrypt
=
encrypt
(
password
);
const
password_encrypt
=
encrypt
(
password
);
return
await
connection
.
oneOrNone
(
'SELECT * FROM academico.func_tma_login_obtener ( $1, $2 );'
,
[
email
,
password_encrypt
]);
return
await
connection
.
oneOrNone
(
'SELECT * FROM academico.func_tma_login_obtener
_v2
( $1, $2 );'
,
[
email
,
password_encrypt
]);
}
else
{
}
else
{
return
await
connection
.
oneOrNone
(
'SELECT * FROM academico.func_tma_login_obtener ( $1 );'
,
[
email
]);
return
await
connection
.
oneOrNone
(
'SELECT * FROM academico.func_tma_login_obtener ( $1 );'
,
[
email
]);
}
}
};
};
const
post_generar_usuario
=
async
({
tipo_operacion
,
correo
,
perfil
})
=>
{
const
contrasenia
=
`Saco+
${
Math
.
floor
(
10000
+
(
Math
.
random
()
*
99999
))}
`
;
const
contrasenia_encriptada
=
encrypt
(
contrasenia
);
const
response
=
await
connection
.
oneOrNone
(
'SELECT * FROM seguridad.func_usuario_actualizar ( $1 );'
,
[{
tipo_operacion
,
correo
,
contrasenia_encriptada
,
perfil
}]);
const
usuario_login
=
response
.
json
.
data
[
"usuario_login"
];
const
response_2
=
await
connection
.
oneOrNone
(
'SELECT * FROM seguridad.func_usuario_listar ( $1 );'
,
[{
tipo_operacion
:
"plantilla_html_tutor_profesor"
,
correo_destinatario
:
correo
,
usuario_login
,
usuario_contrasenia
:
contrasenia
,
plataforma_nombre
:
"TMA"
}]);
const
remitente
=
response_2
.
json
.
data
[
"correo_remitente"
];
const
destinatario
=
response_2
.
json
.
data
[
"correo_destinatario"
];
const
asunto
=
response_2
.
json
.
data
[
"correo_asunto"
];
const
mensaje
=
response_2
.
json
.
data
[
"correo_mensaje"
];
const
url_enviar_correo
=
`
${
process
.
env
.
URL_SO_API_NOTIFICATION
}
/notification/sends/many`
;
const
response_3
=
await
axios
.
post
(
url_enviar_correo
,
{
fromEmail
:
remitente
,
toEmails
:
[
"dtito.ti@sacooliveros.edu.pe"
],
subject
:
asunto
,
mailContent
:
mensaje
});
return
response
;
};
const
get_account
=
async
({
documento
})
=>
{
const
get_account
=
async
({
documento
})
=>
{
return
await
connection
.
oneOrNone
(
'SELECT * FROM academico.func_tma_cuenta_obtener ( $1 );'
,
[
documento
]);
return
await
connection
.
oneOrNone
(
'SELECT * FROM academico.func_tma_cuenta_obtener
_v2
( $1 );'
,
[
documento
]);
};
};
module
.
exports
=
{
module
.
exports
=
{
post_login
,
post_login
,
post_generar_usuario
,
get_account
get_account
};
};
\ No newline at end of file
routes/auth.router.js
View file @
db7bae23
const
express
=
require
(
'express'
);
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
const
router
=
express
.
Router
();
const
{
check
}
=
require
(
'express-validator'
);
const
{
check
}
=
require
(
'express-validator'
);
const
{
post_login
,
get_account
}
=
require
(
'../controllers/auth.controller'
);
const
{
post_login
,
post_generar_usuario
,
get_account
}
=
require
(
'../controllers/auth.controller'
);
const
{
validate_errors
,
validate_jwt
}
=
require
(
'../middlewares'
);
const
{
validate_errors
,
validate_jwt
}
=
require
(
'../middlewares'
);
router
.
post
(
'/login'
,
router
.
post
(
'/login'
,
...
@@ -10,6 +10,12 @@ router.post('/login',
...
@@ -10,6 +10,12 @@ router.post('/login',
validate_errors
,
validate_errors
,
post_login
);
post_login
);
router
.
post
(
'/generar_usuario'
,
check
(
'correo'
,
'Correo inválido'
).
not
().
isEmpty
(),
check
(
'perfil'
,
'Perfil inválido'
).
not
().
isEmpty
(),
validate_errors
,
post_generar_usuario
);
router
.
get
(
'/account'
,
router
.
get
(
'/account'
,
validate_jwt
,
validate_jwt
,
get_account
);
get_account
);
...
...
services/auth.service.js
View file @
db7bae23
...
@@ -4,11 +4,16 @@ const post_login = async (input) => {
...
@@ -4,11 +4,16 @@ const post_login = async (input) => {
return
await
db
.
post_login
(
input
);
return
await
db
.
post_login
(
input
);
};
};
const
post_generar_usuario
=
async
(
input
)
=>
{
return
await
db
.
post_generar_usuario
(
input
);
};
const
get_account
=
async
(
input
)
=>
{
const
get_account
=
async
(
input
)
=>
{
return
await
db
.
get_account
(
input
);
return
await
db
.
get_account
(
input
);
};
};
module
.
exports
=
{
module
.
exports
=
{
post_login
,
post_login
,
post_generar_usuario
,
get_account
get_account
};
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment