-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Feat] #6
Changes from 15 commits
e9f5801
1fcfdcd
f441a79
b0db16b
8dbf399
225d938
dae00fb
157d257
6d30be1
c159d54
de33b55
a542d6e
73ce4cf
a6b9143
376d74d
464729b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| .env | ||
| node_modules | ||
| server-system-425608-fa659756e648.json | ||
| yarn.lock | ||
| yarn.lock | ||
| uploads/* |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,7 @@ | ||||||
| const db = require('../../models/index'); | ||||||
| const dotenv = require('dotenv'); | ||||||
| const db = require('../../models/index'); | ||||||
| const responseMessage = require('../../constants/responseMessage'); | ||||||
| const statusCode = require('../../constants/statusCode'); | ||||||
|
|
||||||
| dotenv.config(); | ||||||
|
|
||||||
|
|
@@ -10,7 +12,7 @@ const join = async (req, res) => { | |||||
|
|
||||||
| // λΉλ°λ²νΈ μΌμΉμ¬λΆ κ²μ¦ λ‘μ§ | ||||||
| if (password !== passwordCheck) { | ||||||
| return res.status(409).send({message: "λΉλ°λ²νΈκ° μΌμΉνμ§ μμ΅λλ€.\nλ€μ μ λ ₯ν΄μ£ΌμΈμ."}); | ||||||
| return res.status(statusCode.CONFLICT).send({message: responseMessage.DIFFRERENT_PASSWORD}); | ||||||
| } | ||||||
|
|
||||||
| // μλ‘μ΄ μ¬μ©μ νμκ°μ | ||||||
|
|
@@ -20,8 +22,8 @@ const join = async (req, res) => { | |||||
| email: email, | ||||||
| password: password | ||||||
| }); | ||||||
| return res.status(200).send({ message: "νμκ°μ λμμ΅λλ€.\nλ‘κ·ΈμΈ ν΄μ£ΌμΈμ."}); | ||||||
|
|
||||||
| return res.status(statusCode.OK).send({ message: responseMessage.CREATED_USER }); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μλ‘μ΄ νμ 리μμ€κ° μμ±λμμΌλ―λ‘, HTTP μν μ½λλ‘
Suggested change
|
||||||
| } | ||||||
| } catch (err) { | ||||||
| res.status(500).send({ | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||
| const db = require('../../models/index'); | ||||||
| const bcrypt = require('bcrypt'); | ||||||
|
|
||||||
| const db = require('../../models/index'); | ||||||
| const statusCode = require('../../constants/statusCode'); | ||||||
| const responseMessage = require('../../constants/responseMessage'); | ||||||
|
|
||||||
| // ν ν°μ μν λͺ¨λ | ||||||
| const jwt = require('jsonwebtoken'); | ||||||
|
|
@@ -12,12 +13,10 @@ const changePassword = async function (req, res) { | |||||
| const { newPassword, doubleCheckNewPassword } = req.body; | ||||||
| const authHeader = req.headers.authorization; | ||||||
| const token = authHeader.split(' ')[1]; | ||||||
|
|
||||||
| console.log(token); | ||||||
|
|
||||||
| // λΉλ°λ²νΈ λλΈμ²΄ν¬ λ‘μ§ | ||||||
| if (newPassword !== doubleCheckNewPassword) { | ||||||
| return res.status(400).send('λΉλ°λ²νΈ λΆμΌμΉ'); | ||||||
| return res.status(statusCode.BAD_REQUEST).send(responseMessage.DIFFRERENT_PASSWORD); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. λ€λ₯Έ API μλ΅κ³Ό μΌκ΄μ±μ μ μ§νκΈ° μν΄, λ¬Έμμ΄ λμ JSON κ°μ²΄ ννλ‘ μλ΅μ 보λ΄λ κ²μ΄ μ’μ΅λλ€.
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| try { | ||||||
|
|
@@ -28,10 +27,8 @@ const changePassword = async function (req, res) { | |||||
|
|
||||||
| const user = decode.user; // νμμΈμ§ μμ¬μΈμ§ κ΅¬λΆ | ||||||
|
|
||||||
| console.log(email); | ||||||
| console.log(user); | ||||||
|
|
||||||
| const hashedNewPassword = await bcrypt.hash(newPassword, 10); | ||||||
| const saltRounds = 10; | ||||||
| const hashedNewPassword = await bcrypt.hash(newPassword, saltRounds); | ||||||
|
|
||||||
| // νμ μ΄λ©μΌμΈ κ²½μ° | ||||||
| if (user == "patient") { | ||||||
|
|
@@ -51,19 +48,18 @@ const changePassword = async function (req, res) { | |||||
| }, | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| // λΉλ°λ²νΈ λ³κ²½ ν ν ν° λ°μ΄ν°λ² μ΄μ€μ μ μ₯λμ΄ μλ ν ν° μμ | ||||||
| const passwordToken = await db.passwordToken.findOne({ where: { email: email } }); | ||||||
| console.log(passwordToken); | ||||||
|
|
||||||
| await passwordToken.destroy(); | ||||||
|
|
||||||
| res.status(200).send({ | ||||||
| message: "λΉλ°λ²νΈ λ³κ²½μ΄ μλ£λμμ΅λλ€.", | ||||||
| res.status(statusCode.OK).send({ | ||||||
| message: responseMessage.SUCCESS_UPDATE_PASSWORD, | ||||||
| token: token | ||||||
| }); | ||||||
| } catch (error) { | ||||||
| res.status(500).send({ message: "λΉλ°λ²νΈ λ³κ²½μ΄ μ€ν¨νμμ΅λλ€.\nλμ€μ λ€μ μλν΄μ£ΌμΈμ."}); | ||||||
| res.status(500).send({ message: responseMessage.FAIL_UPDATE_PASSWORD }); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
| }; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| function showToast(message) { | ||
| const toast = document.getElementById('toast'); | ||
| toast.textContent = message; | ||
| toast.style.display = 'block'; | ||
|
|
||
| setTimeout(() => { | ||
| toast.style.display = 'none'; | ||
| }, 2000); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DIFFRERENT_PASSWORDμ μ€νκ° μμ΅λλ€.DIFFERENT_PASSWORDλ‘ μμ νλ κ²μ΄ μ’κ² μ΅λλ€.