Skip to content

Commit

Permalink
merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish Sharma committed Feb 24, 2024
2 parents 2d57d17 + b5f69cb commit 59fed82
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 68 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ More details at [kilvish.in](https://kilvish.in)
- Due to sharing related changes, android & iOS specific code is written which had broken the web or MacOS builds.
- `flutter build apk --debug && flutter install --debug` will build & install apk in an already running emulator
- To run an Android emulator, install Android Studio & launch an emulator with the AVD manager
- To make it easier to launch emulator every time, add `/path/to/sdk/emulator` to PATH variable & run command `emulator -avd <name of emulator>`
- you can find SDK path from Android Studio -> Settings -> Appearance & Behavior -> Android SDK
- To give a short name to the emulator, launch AVD manager from Android Studio, click on the pencil/edit button of the emulator & give it a short name that you can pass to the emulator command above.

## Firebase Setup

Expand Down
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 }],
},
}
4 changes: 0 additions & 4 deletions functions/.gitignore
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/

Expand Down
151 changes: 151 additions & 0 deletions functions/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions functions/lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 54 additions & 36 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 },
},
})
}
})
15 changes: 15 additions & 0 deletions lib/common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ Widget renderLabel(
)));
}

Widget renderSupportLabel(
{required String text,
Color color = inactiveColor,
double fontSize = smallFontSize,
double topSpacing = 0}) {
return Container(
margin: EdgeInsets.only(top: topSpacing),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
text,
style: TextStyle(color: color, fontSize: fontSize),
)));
}

Widget renderHelperText({required String text}) {
return Container(
margin: const EdgeInsets.only(top: 5, bottom: 10),
Expand Down
Loading

0 comments on commit 59fed82

Please sign in to comment.