Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prjcloud_65160270
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160270
prjcloud_65160270
Commits
b048229f
Commit
b048229f
authored
3 months ago
by
65160270
Browse files
Options
Downloads
Patches
Plain Diff
update-address
parent
b7633640
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
server.js
+0
-3
0 additions, 3 deletions
server.js
shop-routes/user.js
+0
-36
0 additions, 36 deletions
shop-routes/user.js
views/login.ejs
+0
-2
0 additions, 2 deletions
views/login.ejs
with
0 additions
and
41 deletions
server.js
+
0
−
3
View file @
b048229f
...
...
@@ -23,9 +23,6 @@ const isLoggedIn = (req, res, next) => {
}
};
const
userRoutes
=
require
(
"
./routes/user
"
);
// เพิ่มการเรียกใช้งาน
app
.
use
(
"
/user
"
,
userRoutes
);
// เพิ่มการใช้งาน user routes
// Session Configuration
app
.
use
(
session
({
secret
:
process
.
env
.
SESSION_SECRET
||
"
mysecret
"
,
...
...
This diff is collapsed.
Click to expand it.
shop-routes/user.js
deleted
100644 → 0
+
0
−
36
View file @
b7633640
const
express
=
require
(
"
express
"
);
const
bcrypt
=
require
(
"
bcrypt
"
);
const
pool
=
require
(
"
../config/database
"
);
const
router
=
express
.
Router
();
// แสดงฟอร์มเปลี่ยนรหัสผ่าน
router
.
get
(
"
/change-password
"
,
(
req
,
res
)
=>
{
res
.
render
(
"
change-password
"
);
});
// อัปเดตรหัสผ่านใหม่
router
.
post
(
"
/change-password
"
,
async
(
req
,
res
)
=>
{
try
{
const
{
email
,
newPassword
}
=
req
.
body
;
if
(
!
email
||
!
newPassword
)
{
return
res
.
status
(
400
).
send
(
"
กรุณากรอกข้อมูลให้ครบ
"
);
}
// ค้นหาผู้ใช้
const
[
users
]
=
await
pool
.
execute
(
"
SELECT * FROM users WHERE email = ?
"
,
[
email
]);
if
(
users
.
length
===
0
)
{
return
res
.
status
(
400
).
send
(
"
ไม่พบอีเมลนี้ในระบบ
"
);
}
// เข้ารหัสรหัสผ่านใหม่
const
hashedPassword
=
await
bcrypt
.
hash
(
newPassword
,
10
);
await
pool
.
execute
(
"
UPDATE users SET password = ? WHERE email = ?
"
,
[
hashedPassword
,
email
]);
res
.
send
(
"
เปลี่ยนรหัสผ่านสำเร็จ! <a href='/login'>เข้าสู่ระบบ</a>
"
);
}
catch
(
error
)
{
console
.
error
(
error
);
res
.
status
(
500
).
send
(
"
เกิดข้อผิดพลาด
"
);
}
});
module
.
exports
=
router
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
views/login.ejs
+
0
−
2
View file @
b048229f
...
...
@@ -20,8 +20,6 @@
</div>
<button
type=
"submit"
>
Login
</button>
</form>
<p><a
href=
"/user/change-password"
>
ลืมรหัสผ่าน?
</a></p>
<!-- เพิ่มลิงก์เปลี่ยนรหัสผ่าน -->
<p>
Don't have an account?
<a
href=
"/register"
>
Register
</a></p>
</div>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment