Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
* Update template_functions.go

* Update template_functions.go

* Update main.js

* remove useless condition

* Update main.js

* Fix login on nyaa -> log off sukebei issue

* Update user.go

* Update main.js
Cette révision appartient à :
kilo 2017-09-21 06:18:55 +02:00 révisé par ewhal
Parent 6cdab6cbc9
révision cd128df436
3 fichiers modifiés avec 24 ajouts et 6 suppressions

Voir le fichier

@ -88,14 +88,28 @@ parseAllDates()
function resetCookies() {
var cookies = document.cookie.split(";")
var excludedCookies = ["mascot", "version", "theme", "theme2", "mascot_url", "lang", "csrf_token", "altColors", "EU_Cookie", "oldNav"]
var ignoredCookies = ["session"]
//Excluded cookies are either left untouched or deleted then re-created
//Ignored Cookies are constantly left untouched
//Get HostName without subDomain
var hostName = window.location.host
var lastDotIndex = hostName.lastIndexOf(".")
var secondLast = -1
for(var index = 0; index < lastDotIndex; index++) {
if(hostName[index] == '.')
secondLast = index
}
hostName = hostName.substr(secondLast == -1 ? 0 : secondLast)
//Remove all cookies but re-create those in the above array
for (var i = 0; i < cookies.length; i++) {
var cookieName = (cookies[i].split("=")[0]).trim()
//Trim spaces because some cookie names have them at times
if (excludedCookies.includes(cookieName)) {
if(domain == ".pantsu.cat") {
//only execute if cookie are supposed to be shared between nyaa & sukebei
if(domain == hostName) {
//only execute if cookie are supposed to be shared between nyaa & sukebei, aka on host name without subdomain
var cookieValue = getCookieValue(cookieName)
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString + ";domain=" + domain
@ -103,6 +117,9 @@ function resetCookies() {
}
continue
}
if (ignoredCookies.includes(cookieName)) {
continue
}
document.cookie = cookieName + "=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
}

Voir le fichier

@ -331,7 +331,8 @@ func contains(arr interface{}, comp string) bool {
}
func torrentFileExists(hash string, TorrentLink string) bool {
if(len(TorrentLink) > 30 && !kilo_strfind(TorrentLink, ".pantsu.cat", 8)) {
domain := getDomainName()
if(TorrentLink!= "" && domain != "" && !kilo_strfind(TorrentLink, domain, len(domain))) {
return true
}
Openfile, err := os.Open(fmt.Sprintf("%s%c%s.torrent", config.Get().Torrents.FileStorage, os.PathSeparator, hash))

Voir le fichier

@ -96,7 +96,7 @@ func Encode(userID uint, validUntil time.Time) (string, error) {
// Clear : Erase cookie session
func Clear(c *gin.Context) {
c.SetCookie(CookieName, "", -1, "/", getDomainName(), false, true)
c.SetCookie(CookieName, "", -1, "/", "", false, true)
}
// SetLogin sets the authentication cookie
@ -111,7 +111,7 @@ func SetLogin(c *gin.Context, user *models.User) (int, error) {
return http.StatusInternalServerError, err
}
c.SetCookie(CookieName, encoded, maxAge, "/", getDomainName(), false, true)
c.SetCookie(CookieName, encoded, maxAge, "/", "", false, true)
// also set response header for convenience
c.Header("X-Auth-Token", encoded)
return http.StatusOK, nil