-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feat: 휴대폰 번호 인증 구현중
- Loading branch information
Showing
4 changed files
with
110 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* eslint-disable */ | ||
|
||
const functions = require("firebase-functions"); | ||
const admin = require("firebase-admin"); | ||
const twilio = require("twilio"); | ||
|
||
admin.initializeApp(); | ||
|
||
const accountSid = "AC4fcb1e4f01c88548697a10bdd94af92f"; | ||
const authToken = import.meta.env.VITE_APP_TWILLIO_AUTH_TOKEN; | ||
const client = twilio(accountSid, authToken); | ||
|
||
exports.sendVerificationCode = functions.https.onCall(async (data, context) => { | ||
const { phoneNumber } = data; | ||
|
||
try { | ||
const verification = await client.verify | ||
.services("VA955ef896e56fa33814bd1b2efff0f37e") | ||
.verifications.create({ | ||
to: phoneNumber, | ||
channel: "sms" | ||
}); | ||
|
||
return { success: true, verification }; | ||
} catch (error) { | ||
console.error(error); | ||
return { success: false, error: error.message }; | ||
} | ||
}); | ||
|
||
exports.checkVerificationCode = functions.https.onCall(async (data, context) => { | ||
const { phoneNumber, code } = data; | ||
|
||
try { | ||
const check = await client.verify | ||
.services("your_verify_service_sid") | ||
.verificationChecks.create({ | ||
to: phoneNumber, | ||
code | ||
}); | ||
|
||
return check.status === "approved" ? { success: true, check } : { success: false, check }; | ||
} catch (error) { | ||
console.error(error); | ||
return { success: false, error: error.message }; | ||
} | ||
}); |
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