-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
277 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
# Compiled JavaScript files | ||
lib/**/*.js | ||
lib/**/*.js.map | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,37 +18,37 @@ export const helloWorld = functions.https.onRequest(async (request, response) => | |
name: "Radhey", | ||
email: "[email protected]", | ||
phone: "8983026208", | ||
tags: ["tagId1", "tagId2", "tagId3"] | ||
tags: ["tagId1", "tagId2", "tagId3"], | ||
}, | ||
kilvishId2: { | ||
kilvishId: "KilvishId2", | ||
name: "dummy Name", | ||
email: "[email protected]", | ||
phone: "8208567820", | ||
}, | ||
}); | ||
}) | ||
|
||
const tagRef = db.ref("tags") | ||
await tagRef.update({ | ||
tagId1: { | ||
owner: "kilvishId1", | ||
name: "Radhey1", | ||
sharedWith: ["kilvishId2"], | ||
expenses: ["expenses1", "expenses2", "expenses3"] | ||
expenses: ["expenses1", "expenses2", "expenses3"], | ||
}, | ||
tagId2: { | ||
owner: "kilvishId1", | ||
name: "Radhey2", | ||
sharedWith: ["kilvishId2"], | ||
expenses: ["expenses1", "expenses2", "expenses3"] | ||
expenses: ["expenses1", "expenses2", "expenses3"], | ||
}, | ||
tagId3: { | ||
owner: "kilvishId1", | ||
name: "Radhey3", | ||
sharedWith: ["kilvishId2"], | ||
expenses: ["expenses1", "expenses2", "expenses3"] | ||
expenses: ["expenses1", "expenses2", "expenses3"], | ||
}, | ||
}); | ||
}) | ||
|
||
const expensesRef = db.ref("expenses") | ||
await expensesRef.update({ | ||
|
@@ -57,81 +57,99 @@ export const helloWorld = functions.https.onRequest(async (request, response) => | |
from: "kilvishId1", | ||
to: "kilvishId2", | ||
amount: 200, | ||
tags: ["tag1", "tag2", "tag3"] | ||
tags: ["tag1", "tag2", "tag3"], | ||
}, | ||
expenses2: { | ||
timestamp: "2024-02-15 00:45:51.571338", | ||
from: "kilvishId2", | ||
to: "kilvishId1", | ||
amount: 300, | ||
tags: ["tag1", "tag2", "tag3"] | ||
tags: ["tag1", "tag2", "tag3"], | ||
}, | ||
expenses3: { | ||
timestamp: "2024-02-14 00:45:51.571338", | ||
from: "kilvishId1", | ||
to: "kilvishId2", | ||
amount: 400, | ||
tags: ["tag1", "tag2", "tag3"] | ||
tags: ["tag1", "tag2", "tag3"], | ||
}, | ||
}); | ||
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 }, | ||
}, | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.