-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add logout feature * fix bug, optimize display * optimize logout display * keep Logs ui to logout --------- Co-authored-by: luo.pengcheng <[email protected]>
- Loading branch information
1 parent
92354d6
commit abef25c
Showing
5 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package web | ||
|
||
import ( | ||
"net/http" | ||
"time" | ||
) | ||
|
||
func Logout(w http.ResponseWriter, r *http.Request) { | ||
// 创建一个过期的 Cookie 来清除客户端的身份认证 Cookie | ||
expiredCookie := http.Cookie{ | ||
Name: cookieName, // 假设你的身份验证使用的是名为 "auth" 的 Cookie | ||
Value: "", | ||
Path: "/", | ||
Expires: time.Unix(0, 0), // 设置为过期时间 | ||
MaxAge: -1, // 立即删除该 Cookie | ||
HttpOnly: true, | ||
} | ||
// 设置过期的 Cookie | ||
http.SetCookie(w, &expiredCookie) | ||
|
||
// 重定向用户到登录页面 | ||
http.Redirect(w, r, "./login", http.StatusFound) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters