-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkPW.html
136 lines (117 loc) · 3.88 KB
/
checkPW.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css" />
<title>Life Tracker - Mypage</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
font-family: 'Inter', sans-serif;
margin: 0;
padding: 0;
background: white;
}
.form-group {
display: flex;
align-items: center;
justify-content: center;
margin-top: 50px;
}
.form-group input {
margin-right: 10px;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
#confirm {
padding: 10px 20px;
font-size: 16px;
background-color: #cacaca;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
#confirm:hover {
background-color: black;
}
#back-button {
position: fixed;
bottom: 20px;
right: 20px;
padding: 10px 20px;
background-color: #cacaca;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
#back-button:hover {
background-color: black;
}
</style>
</head>
<body>
<h1>Life Tracker</h1>
<ul>
<li><a href="scheduler.html">Scheduler</a></li>
<li class="dropdown">
<a href="timer.html">Timer</a>
<div class="dropdown-content">
<a href="stopwatch.html">Stopwatch</a>
</div>
</li>
<li><a href="song.html">Song</a></li>
<li><a href="diary.html">Diary</a></li>
<li><a href="myPage.html" id="selected-list">My page</a></li>
</ul>
<div class="form-group">
<h2>비밀번호를 입력해주세요</h2>
</div>
<div class="form-group">
<input type="password" id="pwRE" placeholder="password check">
<button id="confirm">확인</button>
</div>
<script type="module">
import { auth, db, ref, set, get, getUserInfo } from './js/firebase.js';
let correctPassword;
auth.onAuthStateChanged(async (user) => {
if (user) {
try {
const userInfo = await getUserInfo(user.uid);
if (userInfo) {
const userName = userInfo.name;
const userUid = userInfo.uid;
let path = `users/${userUid}`;
const userSnapshot = await get(ref(db, path));
const uservalue = userSnapshot.val();
correctPassword = uservalue.password;
console.log(correctPassword);
} else {
console.error('사용자 정보가 없습니다.');
}
} catch (error) {
console.error('사용자 정보를 가져오는 중 에러 발생:', error);
}
} else {
console.log('사용자가 로그인하지 않았습니다.');
}
});
document.getElementById('confirm').addEventListener('click', () => {
const enteredPassword = document.getElementById('pwRE').value;
if (enteredPassword === correctPassword) {
window.location.href = 'infoModify.html';
} else {
alert('비밀번호가 틀렸습니다.');
}
});
</script>
<button type="button" id="back-button">Back</button>
<script>
document.getElementById('back-button').addEventListener('click', () => {
window.location.href = 'myPage.html';
});
</script>
</body>
</html>