๐ ํ์ํ ๊ธฐ๋ฅ
ํ๊ต ์ ํ -> ํด๋น ํ๊ต ์ด๋ฉ์ผ ๋ท๋ถ๋ถ(์๋ฅผ ๋ค์ด @korea.ac.kr) ํ์ธ -> ์ผ์นํ๋ค๋ฉด ์ ๋ ฅํ ์ด๋ฉ์ผ๋ก ๋ฉ์ผ ์ ์ก -> ์ธ์ฆ
์ด๋ฐ ๋ก์ง์ผ๋ก ํ๊ต ์ธ์ฆ์ ๊ตฌํํ์๋ค.
firebase๋ฅผ ์ฌ์ฉํ๋ฉด ์ด๋ฉ์ผ ์ธ์ฆ๋ ์ฝ๊ฒ ๊ตฌํํ ์ ์๋ค.
๐ ์ด๋ฉ์ผ ์ ์ก ์ฝ๋
// ๋ก๊ทธ์ธ ๋ฐ ๋ฉ์ผ ์ ์ก
const sentEmail = await signInWithEmailAndPassword(firebaseAuth, email, password)
.then(() => {
sendEmailVerification(firebaseAuth.currentUser);
return { err: false };
})
.catch((e) => {
console.log(e);
return { err: true, error: e };
});
if (sentEmail.err) {
return res
.status(statusCode.INTERNAL_SERVER_ERROR)
.send(util.fail(statusCode.INTERNAL_SERVER_ERROR,
responseMessage.SEND_VERIFICATION_EMAIL_FAIL));
}
๐ ์ธ์ฆ ์ฌ๋ถ ํ์ธ ์ฝ๋
const userFirebase = await signInWithEmailAndPassword(firebaseAuth, email, password)
.then((user) => user)
.catch((e) => {
console.log(e);
return { err: true, error: e };
});
...
const {
user: { uid: firebaseId, emailVerified: isEmailVerified },
} = userFirebase;
// const firebaseId = userFirebase.user.uid;
// const isEmailVerified = userFirebase.user.emailVerified; ์ ๋์ผ
if(!isEmailVerfied) {
// ์ด๋ฉ์ผ ์ธ์ฆ์ด ๋์ง ์์ ์ ์ ์ ๋ํ ์ฒ๋ฆฌ
}
์ธ์ฆ ์ฌ๋ถ๋ ๋ก๊ทธ์ธ ์ ๋ณด์ emailVerifed๋ฅผ ๊ฐ์ง๊ณ ์ฒ๋ฆฌํด์ฃผ์๋ค.
๐ ์ด๋ฉ์ผ ์ ์ก์์ ์ด๋ ค์ ๋ ์
serverless ํ๊ฒฝ์ด ์๋๋ผ ์๋ฒ์ธก์์ ์ด๋ฉ์ผ ์ธ์ฆ์ ๊ตฌํํ์๊ธฐ ๋๋ฌธ์ ํด๋น ์ ์ ๊ฐ ๋ก๊ทธ์ธ์ด ๋์ด์๋์ง ์ ์ ์๋ค.
๋ฐ๋ผ์ ๋ก๊ทธ์ธ์ ์ํค๊ณ ์ด๋ฉ์ผ์ ์ ์กํด์ผ ํ๋ค.
signInWithEmailAndPassword๋ก ๋ก๊ทธ์ธ์ ์ํค๊ณ ๊ทธ ์ดํ sendEmailVerification์ ์ฌ์ฉํ์ฌ ์ธ์ฆ ๋ฉ์ผ์ ๋ณด๋ธ๋ค.
'Programming > Node.js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Nodejs] Express ๊ตฌ์กฐ ๋ฏ์ด๋ณด๊ธฐ (0) | 2022.04.05 |
---|---|
[Nodejs] express๋ฅผ ์ด์ฉํ ์๋ฒ ๊ตฌ์ถ (0) | 2022.03.31 |
[Nodejs] firebase FCM์ ์ด์ฉํ pushAlarm ์๋ฒ ๊ตฌํ - ์๋ฆฌ ์ค์ (5) | 2022.02.04 |
[Nodejs] firebase FCM์ ์ด์ฉํ pushAlarm ์๋ฒ ๊ตฌํ (0) | 2022.01.21 |