DUANY\DuanY %!s(int64=4) %!d(string=hai) anos
pai
achega
515c9807d7

+ 22 - 19
.idea/workspace.xml

@@ -2,10 +2,12 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="c5a24e7a-e8cf-45f7-8d0b-25810e3d773a" name="默认更改列表" comment="">
-      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/sso-login/src/main/java/com/sso/login/controller/LoginController.java" beforeDir="false" afterPath="$PROJECT_DIR$/sso-login/src/main/java/com/sso/login/controller/LoginController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/sso-login/src/main/java/com/sso/login/controller/ViewController.java" beforeDir="false" afterPath="$PROJECT_DIR$/sso-login/src/main/java/com/sso/login/controller/ViewController.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/sso-login/target/classes/com/sso/login/controller/LoginController.class" beforeDir="false" afterPath="$PROJECT_DIR$/sso-login/target/classes/com/sso/login/controller/LoginController.class" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/sso-main/src/main/java/com/sso/main/controller/ViewController.java" beforeDir="false" afterPath="$PROJECT_DIR$/sso-main/src/main/java/com/sso/main/controller/ViewController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/sso-main/src/main/resources/templates/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/sso-main/src/main/resources/templates/index.html" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/sso-main/target/classes/com/sso/main/controller/ViewController.class" beforeDir="false" afterPath="$PROJECT_DIR$/sso-main/target/classes/com/sso/main/controller/ViewController.class" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/sso-main/target/classes/templates/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/sso-main/target/classes/templates/index.html" afterDir="false" />
     </list>
@@ -117,9 +119,9 @@
     </list>
     <recent_temporary>
       <list>
-        <item itemvalue="Spring Boot.MainApp" />
-        <item itemvalue="Spring Boot.LoginApp" />
         <item itemvalue="Spring Boot.VipApp" />
+        <item itemvalue="Spring Boot.LoginApp" />
+        <item itemvalue="Spring Boot.MainApp" />
       </list>
     </recent_temporary>
   </component>
@@ -137,6 +139,7 @@
       <workItem from="1608614660628" duration="4822000" />
       <workItem from="1608631578360" duration="4551000" />
       <workItem from="1608684196974" duration="240000" />
+      <workItem from="1609115341694" duration="4316000" />
     </task>
     <servers />
   </component>
@@ -168,38 +171,38 @@
       <screen x="0" y="0" width="1920" height="1050" />
     </state>
     <state x="1154" y="286" key="FileChooserDialogImpl/0.0.1920.1050@0.0.1920.1050" timestamp="1608599626317" />
-    <state width="1877" height="282" key="GridCell.Tab.0.bottom" timestamp="1608639417874">
+    <state width="1877" height="281" key="GridCell.Tab.0.bottom" timestamp="1609119665246">
       <screen x="0" y="0" width="1920" height="1050" />
     </state>
-    <state width="1877" height="282" key="GridCell.Tab.0.bottom/0.0.1920.1050@0.0.1920.1050" timestamp="1608639417874" />
-    <state width="1877" height="282" key="GridCell.Tab.0.center" timestamp="1608639417874">
+    <state width="1877" height="281" key="GridCell.Tab.0.bottom/0.0.1920.1050@0.0.1920.1050" timestamp="1609119665246" />
+    <state width="1877" height="281" key="GridCell.Tab.0.center" timestamp="1609119665246">
       <screen x="0" y="0" width="1920" height="1050" />
     </state>
-    <state width="1877" height="282" key="GridCell.Tab.0.center/0.0.1920.1050@0.0.1920.1050" timestamp="1608639417874" />
-    <state width="1877" height="282" key="GridCell.Tab.0.left" timestamp="1608639417874">
+    <state width="1877" height="281" key="GridCell.Tab.0.center/0.0.1920.1050@0.0.1920.1050" timestamp="1609119665246" />
+    <state width="1877" height="281" key="GridCell.Tab.0.left" timestamp="1609119665246">
       <screen x="0" y="0" width="1920" height="1050" />
     </state>
-    <state width="1877" height="282" key="GridCell.Tab.0.left/0.0.1920.1050@0.0.1920.1050" timestamp="1608639417874" />
-    <state width="1877" height="282" key="GridCell.Tab.0.right" timestamp="1608639417874">
+    <state width="1877" height="281" key="GridCell.Tab.0.left/0.0.1920.1050@0.0.1920.1050" timestamp="1609119665246" />
+    <state width="1877" height="281" key="GridCell.Tab.0.right" timestamp="1609119665246">
       <screen x="0" y="0" width="1920" height="1050" />
     </state>
-    <state width="1877" height="282" key="GridCell.Tab.0.right/0.0.1920.1050@0.0.1920.1050" timestamp="1608639417874" />
-    <state width="1877" height="282" key="GridCell.Tab.1.bottom" timestamp="1608639417874">
+    <state width="1877" height="281" key="GridCell.Tab.0.right/0.0.1920.1050@0.0.1920.1050" timestamp="1609119665246" />
+    <state width="1877" height="281" key="GridCell.Tab.1.bottom" timestamp="1609119665246">
       <screen x="0" y="0" width="1920" height="1050" />
     </state>
-    <state width="1877" height="282" key="GridCell.Tab.1.bottom/0.0.1920.1050@0.0.1920.1050" timestamp="1608639417874" />
-    <state width="1877" height="282" key="GridCell.Tab.1.center" timestamp="1608639417874">
+    <state width="1877" height="281" key="GridCell.Tab.1.bottom/0.0.1920.1050@0.0.1920.1050" timestamp="1609119665246" />
+    <state width="1877" height="281" key="GridCell.Tab.1.center" timestamp="1609119665246">
       <screen x="0" y="0" width="1920" height="1050" />
     </state>
-    <state width="1877" height="282" key="GridCell.Tab.1.center/0.0.1920.1050@0.0.1920.1050" timestamp="1608639417874" />
-    <state width="1877" height="282" key="GridCell.Tab.1.left" timestamp="1608639417874">
+    <state width="1877" height="281" key="GridCell.Tab.1.center/0.0.1920.1050@0.0.1920.1050" timestamp="1609119665246" />
+    <state width="1877" height="281" key="GridCell.Tab.1.left" timestamp="1609119665246">
       <screen x="0" y="0" width="1920" height="1050" />
     </state>
-    <state width="1877" height="282" key="GridCell.Tab.1.left/0.0.1920.1050@0.0.1920.1050" timestamp="1608639417874" />
-    <state width="1877" height="282" key="GridCell.Tab.1.right" timestamp="1608639417874">
+    <state width="1877" height="281" key="GridCell.Tab.1.left/0.0.1920.1050@0.0.1920.1050" timestamp="1609119665246" />
+    <state width="1877" height="281" key="GridCell.Tab.1.right" timestamp="1609119665246">
       <screen x="0" y="0" width="1920" height="1050" />
     </state>
-    <state width="1877" height="282" key="GridCell.Tab.1.right/0.0.1920.1050@0.0.1920.1050" timestamp="1608639417874" />
+    <state width="1877" height="281" key="GridCell.Tab.1.right/0.0.1920.1050@0.0.1920.1050" timestamp="1609119665246" />
     <state x="880" y="103" key="SettingsEditor" timestamp="1608599446226">
       <screen x="0" y="0" width="1920" height="1050" />
     </state>

+ 1 - 0
sso-login/src/main/java/com/sso/login/controller/LoginController.java

@@ -47,6 +47,7 @@ public class LoginController {
             Cookie cookie=new Cookie("TOKEN",token);
             //定义域为codeshop.com
             cookie.setDomain("codeshop.com");
+            cookie.setMaxAge(1000);
             response.addCookie(cookie);
             LogCacheUtil.loginUser.put(token, first.get());
         }else{

+ 1 - 3
sso-login/src/main/java/com/sso/login/controller/ViewController.java

@@ -2,10 +2,8 @@ package com.sso.login.controller;
 
 import com.sso.login.pojo.User;
 import com.sso.login.utils.LogCacheUtil;
-import org.springframework.boot.web.servlet.server.Session;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.CookieValue;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.thymeleaf.util.StringUtils;
@@ -24,7 +22,7 @@ public class ViewController {
                           HttpSession session, @CookieValue(required = false,value = "TOKEN")Cookie cookie){
 
         if (StringUtils.isEmpty(target)){
-            target="http://www.codeshop.com";
+            target="http://www.codeshop.com/view/main";
         }
         //如果cookie存在,执行语句
         if (cookie!=null){

BIN=BIN
sso-login/target/classes/com/sso/login/controller/LoginController.class


BIN=BIN
sso-login/target/classes/com/sso/login/controller/ViewController.class


+ 17 - 0
sso-main/src/main/java/com/sso/main/controller/ViewController.java

@@ -38,6 +38,23 @@ public class ViewController {
         return "index";
     }
 
+    @RequestMapping("/delete")
+    public String deleteLogin(@CookieValue(required = false,value = "TOKEN")Cookie cookie,HttpServletResponse response){
+        if (cookie!=null){
+            String token=cookie.getValue();
+            if(!StringUtils.isEmpty(token)){
+                Cookie cookie1=new Cookie("TOKEN",null);
+                cookie1.setDomain("codeshop.com");
+                cookie1.setMaxAge(0);
+                cookie1.setPath("/");
+                response.addCookie(cookie1);
+
+
+            }
+        }
+        return "index";
+    }
+
 
 }
 

+ 5 - 3
sso-main/src/main/resources/templates/index.html

@@ -10,8 +10,10 @@
         <a th:if="${session.loginUser==null}" href="http://login.codeshop.com/view/login?target=http://www.codeshop.com/view/main">登录</a>
     </span>
 
-<p th:unless="${session.loginUser==null}">
-    <span style="color: aqua" th:text="${session.loginUser.username}"></span> 已登录
-</p>
+    <p th:unless="${session.loginUser==null}">
+        <span style="color: aqua" th:text="${session.loginUser.username}"></span> 已登录
+    </p>
+
+    <a th:unless="${session.loginUser==null}" href="http://www.codeshop.com/view/delete">退出</a>
 </body>
 </html>

BIN=BIN
sso-main/target/classes/com/sso/main/controller/ViewController.class


+ 5 - 4
sso-main/target/classes/templates/index.html

@@ -8,11 +8,12 @@
     <h1>这是主页</h1>
     <span>
         <a th:if="${session.loginUser==null}" href="http://login.codeshop.com/view/login?target=http://www.codeshop.com/view/main">登录</a>
-        <a th:unless="${session.loginUser==null}" href="http://www.codeshop.com/view/remove">退出</a>
     </span>
 
-<p th:unless="${session.loginUser==null}">
-    <span style="color: aqua" th:text="${session.loginUser.username}"></span> 已登录
-</p>
+    <p th:unless="${session.loginUser==null}">
+        <span style="color: aqua" th:text="${session.loginUser.username}"></span> 已登录
+    </p>
+
+    <a th:unless="${session.loginUser==null}" href="http://www.codeshop.com/view/delete">退出</a>
 </body>
 </html>