최정민

FEAT : 회원프로필 창 추가

-
1 ###초기설정 1 ###초기설정
2 >####데이터 베이스 설정 2 >####데이터 베이스 설정
3 > <pre><code> 3 > <pre><code>
4 ->CREATE TABLE USER( 4 +> CREATE TABLE USER(
5 ->ID int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, 5 +> ID int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
6 ->EMAIL varchar(64) NOT NULL UNIQUE, 6 +> EMAIL varchar(64) NOT NULL UNIQUE,
7 ->NAME varchar(64) NOT NULL, 7 +> NAME varchar(64) NOT NULL,
8 ->NICKNAME varchar(32) UNIQUE, 8 +> NICKNAME varchar(32) UNIQUE,
9 ->AGE varchar(32), 9 +> AGE int(16),
10 ->GENDER varchar(32) 10 +> GENDER varchar(32),
11 ->); 11 +> PICTURE varchar(128) NOT NULL
12 +> );
12 </code> 13 </code>
13 </pre> 14 </pre>
14 15
15 > <pre><code> 16 > <pre><code>
16 ->CREATE TABLE COMMENT( 17 +> CREATE TABLE COMMENT(
17 ->ID int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, 18 +> ID int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
18 ->CAFE_ID int(10) NOT NULL 19 +> CAFE_ID int(10) NOT NULL
19 ->PRICE int(10) NOT NULL, 20 +> PRICE int(10) NOT NULL,
20 ->KINDNESS int(10) NOT NULL, 21 +> KINDNESS int(10) NOT NULL,
21 ->NOISE int(10) NOT NULL, 22 +> NOISE int(10) NOT NULL,
22 ->ACCESSIBILITY int(10) NOT NULL 23 +> ACCESSIBILITY int(10) NOT NULL
23 ->); 24 +> );
24 </code> 25 </code>
25 </pre> 26 </pre>
26 27
......
...@@ -63,6 +63,7 @@ router.get("/login", checkAuthenticated, (req, res) => { ...@@ -63,6 +63,7 @@ router.get("/login", checkAuthenticated, (req, res) => {
63 req.session.user =req.user; 63 req.session.user =req.user;
64 req.session.user.email = req.user.email; 64 req.session.user.email = req.user.email;
65 req.session.user.name=req.user.name; 65 req.session.user.name=req.user.name;
66 + req.session.user.picture=req.user.picture;
66 var sql = "SELECT * FROM USER WHERE EMAIL=?"; 67 var sql = "SELECT * FROM USER WHERE EMAIL=?";
67 var parameter = [req.session.user.email]; 68 var parameter = [req.session.user.email];
68 connection.query(sql, parameter, function (err, row) { 69 connection.query(sql, parameter, function (err, row) {
...@@ -83,9 +84,7 @@ router.get("/login", checkAuthenticated, (req, res) => { ...@@ -83,9 +84,7 @@ router.get("/login", checkAuthenticated, (req, res) => {
83 }); 84 });
84 85
85 router.post("/login", (req, res) => { 86 router.post("/login", (req, res) => {
86 - console.log(req.body.nickname); 87 + console.log("구글로그인 성공");
87 - console.log(req.body.age);
88 - console.log(req.body.gender);
89 var sql = " SELECT * FROM USER WHERE NICKNAME=?"; 88 var sql = " SELECT * FROM USER WHERE NICKNAME=?";
90 var parameter = [req.body.nickname]; 89 var parameter = [req.body.nickname];
91 connection.query(sql, parameter, function (err, row) { 90 connection.query(sql, parameter, function (err, row) {
...@@ -135,6 +134,7 @@ function checkAuthenticated(req, res, next) { ...@@ -135,6 +134,7 @@ function checkAuthenticated(req, res, next) {
135 const payload = ticket.getPayload(); 134 const payload = ticket.getPayload();
136 user.name = payload.name; 135 user.name = payload.name;
137 user.email = payload.email; 136 user.email = payload.email;
137 + user.picture = payload.picture;
138 } 138 }
139 verify() 139 verify()
140 .then(() => { 140 .then(() => {
......
1 -{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622068485937,"user":{"name":"최정민","email":"cjm104174@gmail.com","nickname":"Mayf","age":"24","gender":"male"}}
...\ No newline at end of file ...\ No newline at end of file
1 +{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622070807469,"user":{"name":"최정민","email":"cjm104174@gmail.com","picture":"https://lh3.googleusercontent.com/a-/AOh14Gh3nytGsPbviGhkznR8HIwrL6o7xBIoFL08nIeU=s96-c","nickname":"Mayf","age":25,"gender":"male"}}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -93,7 +93,6 @@ ...@@ -93,7 +93,6 @@
93 </div> 93 </div>
94 </section> 94 </section>
95 95
96 - <a href="/logout" onclick="signOut();">Sign Out</a>
97 <%if (message=='same nickname'){%> 96 <%if (message=='same nickname'){%>
98 <script type="text/javascript"> 97 <script type="text/javascript">
99 alert( 98 alert(
......
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
287 287
288 <!-- 모달 바디 --> 288 <!-- 모달 바디 -->
289 <div class="modal fade" id="profile" tabindex="-1" role="dialog" aria-labelledby="profilemodal" aria-hidden="true"> 289 <div class="modal fade" id="profile" tabindex="-1" role="dialog" aria-labelledby="profilemodal" aria-hidden="true">
290 - <div class="modal-dialog modal-lg" role="document"> 290 + <div class="modal-dialog" role="document">
291 <div class="modal-content"> 291 <div class="modal-content">
292 <div class="modal-header"> 292 <div class="modal-header">
293 <h5 class="modal-title" id="profilemodal"><%=user.nickname%>'s PROFILE</h5> 293 <h5 class="modal-title" id="profilemodal"><%=user.nickname%>'s PROFILE</h5>
...@@ -296,11 +296,24 @@ ...@@ -296,11 +296,24 @@
296 </button> 296 </button>
297 </div> 297 </div>
298 <div class="modal-body text-center"> 298 <div class="modal-body text-center">
299 - <p>모달바</p> 299 + <div class="card mb-3">
300 + <div class="row g-0">
301 + <div class="col-md-4">
302 + <img src="<%= user.picture%>" alt="google profile picture" style="width:100%; height: 100%; ">
303 + </div>
304 + <div class="col-md-8">
305 + <div class="card-body">
306 + <h5 class="card-title"><%=user.name%></h5>
307 + <p class="card-text">Age : <%=user.age%>, Gender : <%=user.gender%></p>
308 + <p class="card-text">Emaile : <%=user.email%>
309 + <p class="card-text"><small class="text-muted">from Google and CafeRecommend</small></p>
310 + </div>
311 + </div>
312 + </div>
313 + </div>
300 </div> 314 </div>
301 - <div class="modal-footer"> 315 +
302 <button type="button" class="btn btn-primary" data-dismiss="modal">확인</button> 316 <button type="button" class="btn btn-primary" data-dismiss="modal">확인</button>
303 - </div>
304 </div> 317 </div>
305 </div> 318 </div>
306 </div> 319 </div>
......