This repository has been archived on 2024-05-08. You can view files and clone it, but cannot push or open issues or pull requests.
2021-02-19 20:58:03 +03:00

23 lines
934 B
Java

package ru.redguy.webinfomod.pages.logout;
import fi.iki.elonen.NanoHTTPD;
import ru.redguy.webinfomod.*;
import ru.redguy.webinfomod.langs.Localization;
import ru.redguy.webinfomod.utils.WebUtils;
import java.io.IOException;
@WebPage(url = "/logout")
public class Index implements IWebPage {
public NanoHTTPD.Response getPage(Config config, NanoHTTPD.IHTTPSession session) throws IOException {
WebUtils.CookieHandler ch = new WebUtils.CookieHandler(session.getHeaders());
config.getLogger().info(LoggerType.Web,WebStatic.sessions.get(ch.read("session"))+ " has been logout!");
WebStatic.sessions.remove(ch.read("session"));
ch.delete("session");
NanoHTTPD.Response response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.REDIRECT,NanoHTTPD.MIME_PLAINTEXT,"");
response.addHeader("Location", "/");
ch.unloadQueue(response);
return response;
}
}