forked from Daniel-MundosE/modulo-practica-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (40 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
exports.handler = async (event) => {
console.log(event);
const loginData = loginAdapter(event);
const isValid = validateLoginData(loginData);
var data = responseAdapter(isValid, loginData);
return data;
};
const loginAdapter = (body) => {
const loginData = {
usuario: body.user,
email: body.email,
password: body.password,
confirmPassword: body.confirmpwd,
}
return loginData;
}
const responseAdapter = (isValid, loginData) =>{
var data = {
message: "Usuario: " + loginData.usuario + " fue creado exitozamente"
}
if (!isValid) {
data.message = "Ocurrio un error al crear el usuario " + loginData.usuario;
}
return data;
}
const validateLoginData = (loginData) => {
console.log(loginData);
if (required(loginData.usuario) && required(loginData.email)
&& required(loginData.password) && required(loginData.confirmPassword)) {
return true;
}
else
return false;
}
function required(inputtx) {
if (inputtx) {
return true;
}
return false;
}