Skip to content

Commit

Permalink
fixed eslint & prettier conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish Sharma committed Feb 17, 2024
1 parent b11d4e7 commit 0b3b10c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 27 deletions.
2 changes: 1 addition & 1 deletion functions/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ module.exports = {
semi: ["error", "never"],
quotes: ["error", "double"],
"import/no-unresolved": 0,
"max-len": ["error", { code: 90 }],
"max-len": ["error", { code: 120 }],
},
}
70 changes: 44 additions & 26 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,64 +26,82 @@ export const helloWorld = functions.https.onRequest(async (request, response) =>
phone: "8208567820",
},
})
console.log(request.params);
console.log(request.params)
const snapshot = await db.ref("users/kilvishId1").get()
response.send(snapshot.val())
})

export const verifyOtp = functions.https.onRequest(async (request, response) => {
const reqBody = JSON.stringify(request.body);
const data = JSON.parse(reqBody)['data'];
const reqBody = JSON.stringify(request.body)
const data = JSON.parse(reqBody)["data"]

const kilvishId = data["kilvishId"];
const phoneOtp = data["phoneOtp"];
const emailOtp = data["emailOtp"];
const kilvishId = data["kilvishId"]
const phoneOtp = data["phoneOtp"]
const emailOtp = data["emailOtp"]

const snapshot = await db.ref(`users/${kilvishId}`).get()
if (snapshot != null && snapshot.val()) {
const additionalInfo = {
email: snapshot.val()["email"],
phone: snapshot.val()["phone"],
};
}
if (snapshot.val()["verifyPhone"] && snapshot.val()["verifyEmail"]) {
if (phoneOtp == "0000" && emailOtp == "0000") {
const customToken = await getAuth().createCustomToken(kilvishId, additionalInfo);
response.status(200).send({ "data": { "success": true, "token": customToken } })
const customToken = await getAuth().createCustomToken(kilvishId, additionalInfo)
response.status(200).send({ data: { success: true, token: customToken } })
}
} else {
if (phoneOtp == "1234" && emailOtp == "5678") {
const customToken = await getAuth().createCustomToken(kilvishId, additionalInfo);
const usersRef = db.ref("users");
const userInfo = { [kilvishId]: { "kilvishId": kilvishId, "email": snapshot.val()["email"], "phone": snapshot.val()["phone"], "verifyPhone": true, "verifyEmail": true } };
const customToken = await getAuth().createCustomToken(kilvishId, additionalInfo)
const usersRef = db.ref("users")
const userInfo = {
[kilvishId]: {
kilvishId: kilvishId,
email: snapshot.val()["email"],
phone: snapshot.val()["phone"],
verifyPhone: true,
verifyEmail: true,
},
}
await usersRef.update(userInfo)
response.status(200).send({ "data": { "success": true, "token": customToken } })
response.status(200).send({ data: { success: true, token: customToken } })
}
}
}
response.status(400).send({ "data": { "success": false, "message": "User Not Found" } })
response.status(400).send({ data: { success: false, message: "User Not Found" } })
})

export const verifyUser = functions.https.onRequest(async (request, response) => {
const reqBody = JSON.stringify(request.body);
const data = JSON.parse(reqBody)['data'];
const reqBody = JSON.stringify(request.body)
const data = JSON.parse(reqBody)["data"]

const kilvishId = data["kilvishId"];
const email = data["email"];
const phone = data["phone"];
const kilvishId = data["kilvishId"]
const email = data["email"]
const phone = data["phone"]

const userInfo = { [kilvishId]: { "kilvishId": kilvishId, "email": email, "phone": phone } };
const userInfo = { [kilvishId]: { kilvishId: kilvishId, email: email, phone: phone } }
const snapshot = await db.ref(`users/${kilvishId}`).get()
if (snapshot != null && snapshot.val()) {
if (snapshot.val()["email"] == email && snapshot.val()["phone"] == phone) {
/// Logic for send OTP
response.status(200).send({ "data": { "success": true } })
// / Logic for send OTP
response.status(200).send({ data: { success: true } })
} else {
response.status(404).send({ "data": { "success": false, "message": "Wrong email phone number please enter correct correct" } })
response.status(404).send({
data: {
success: false,
message: "Wrong email phone number please enter correct correct",
},
})
}
} else {
const usersRef = db.ref("users");
const usersRef = db.ref("users")
await usersRef.update(userInfo)
/// Logic for send OTP
response.status(201).send({ 'data': { "success": true, "userInfo": { "kilvishId": kilvishId, "email": email, "phone": phone } } })
// / Logic for send OTP
response.status(201).send({
data: {
success: true,
userInfo: { kilvishId: kilvishId, email: email, phone: phone },
},
})
}
})

0 comments on commit 0b3b10c

Please sign in to comment.