This commit is contained in:
Nazar Kanaev 2021-02-12 10:31:00 +00:00
parent e8a002d535
commit 6a828532cb
4 changed files with 23 additions and 0 deletions

View File

@ -92,6 +92,9 @@
body: new FormData(form),
})
},
logout: function() {
return api('post', './logout')
},
crawl: function(url) {
return fetch('./page?url=' + url).then(function(res) {
return res.text()

View File

@ -509,6 +509,11 @@ var vm = new Vue({
vm.refreshStats()
})
},
logout: function() {
api.logout().then(function() {
document.location.reload()
})
},
getReadable: function(item) {
if (this.itemSelectedReadability) {
this.itemSelectedReadability = null

View File

@ -39,6 +39,15 @@ func userAuthenticate(rw http.ResponseWriter, username, password string) {
http.SetCookie(rw, &cookie)
}
func userLogout(rw http.ResponseWriter) {
cookie := http.Cookie{
Name: "auth",
Value: "",
MaxAge: -1,
}
http.SetCookie(rw, &cookie)
}
func stringsEqual(p1, p2 string) bool {
return subtle.ConstantTimeCompare([]byte(p1), []byte(p2)) == 1
}

View File

@ -40,6 +40,7 @@ var routes []Route = []Route{
p("/opml/import", OPMLImportHandler),
p("/opml/export", OPMLExportHandler),
p("/page", PageCrawlHandler),
p("/logout", LogoutHandler),
}
type asset struct {
@ -528,3 +529,8 @@ func PageCrawlHandler(rw http.ResponseWriter, req *http.Request) {
}
}
}
func LogoutHandler(rw http.ResponseWriter, req *http.Request) {
userLogout(rw)
rw.WriteHeader(http.StatusNoContent)
}