mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-11-03 18:00:11 +00:00 
			
		
		
		
	Use same meta data for creating and deleting cookie
The cookie might not be removed by browsers, if these infos don't match.
This commit is contained in:
		@@ -34,4 +34,16 @@ object CookieData {
 | 
				
			|||||||
  def fromHeader[F[_]](req: Request[F]): Either[String, String] = {
 | 
					  def fromHeader[F[_]](req: Request[F]): Either[String, String] = {
 | 
				
			||||||
    req.headers.get(CaseInsensitiveString(headerName)).map(_.value).toRight("Couldn't find an authenticator")
 | 
					    req.headers.get(CaseInsensitiveString(headerName)).map(_.value).toRight("Couldn't find an authenticator")
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def deleteCookie(cfg: Config): ResponseCookie =
 | 
				
			||||||
 | 
					    ResponseCookie(
 | 
				
			||||||
 | 
					      cookieName,
 | 
				
			||||||
 | 
					      "",
 | 
				
			||||||
 | 
					      domain = cfg.baseUrl.host,
 | 
				
			||||||
 | 
					      path = Some(cfg.baseUrl.path / "api" / "v1" / "sec").map(_.asString),
 | 
				
			||||||
 | 
					      httpOnly = true,
 | 
				
			||||||
 | 
					      secure = cfg.baseUrl.scheme.exists(_.endsWith("s")),
 | 
				
			||||||
 | 
					      maxAge = Some(-1)
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,7 @@ object LoginRoutes {
 | 
				
			|||||||
          flatMap(res => makeResponse(dsl, cfg, res, ""))
 | 
					          flatMap(res => makeResponse(dsl, cfg, res, ""))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      case POST -> Root / "logout" =>
 | 
					      case POST -> Root / "logout" =>
 | 
				
			||||||
        Ok().map(_.addCookie(ResponseCookie(CookieData.cookieName, "", maxAge = Some(-1))))
 | 
					        Ok().map(_.addCookie(CookieData.deleteCookie(cfg)))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user