Fixes, cookie fixes

This commit is contained in:
Norbi Peti 2018-05-29 01:16:27 +02:00
parent 919e57a2a9
commit 78ef0fed4b
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 11 additions and 11 deletions

View file

@ -21,7 +21,7 @@ public class LoginCommand extends PlayerCommandBase {
"§6---- Login ----", // "§6---- Login ----", //
"This command allows you to log in to our website using your Minecraft account.", // "This command allows you to log in to our website using your Minecraft account.", //
"If you are already logged in to the site, you can connect your MC account to it.", // "If you are already logged in to the site, you can connect your MC account to it.", //
"This is good for getting Minecraft rewards if you're a patreon for example." // "This is good for getting Minecraft rewards if you're a patron for example." //
}; };
} }
} }

View file

@ -33,8 +33,8 @@ public class Cookies extends HashMap<String, Cookie> {
public void AddHeaders(HttpExchange exchange) { public void AddHeaders(HttpExchange exchange) {
for (Entry<String, Cookie> item : entrySet()) for (Entry<String, Cookie> item : entrySet())
exchange.getResponseHeaders().add("Set-Cookie", exchange.getResponseHeaders().add("Set-Cookie",
item.getKey() + "=" + item.getValue().getValue() + "; expires=" + expiretime); item.getKey() + "=" + item.getValue().getValue() + "; expires=" + expiretime + "; Secure; HttpOnly; Domain=figytuna.com"); //Allow for frontend
exchange.getResponseHeaders().add("Set-Cookie", "expiretime=" + expiretime + "; expires=" + expiretime); exchange.getResponseHeaders().add("Set-Cookie", "expiretime=" + expiretime + "; expires=" + expiretime + "; Secure; HttpOnly; Domain=figytuna.com");
} }
public Cookies add(Cookie cookie) { public Cookies add(Cookie cookie) {

View file

@ -44,7 +44,7 @@ public class LoginPage extends Page {
IOHelper.LoginUser(exchange, wu); IOHelper.LoginUser(exchange, wu);
states.remove(state); states.remove(state);
try { try {
return IOHelper.Redirect("https://tbmcplugins.github.io/", exchange); return IOHelper.Redirect("https://chromagaming.figytuna.com/", exchange);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View file

@ -1,16 +1,16 @@
package buttondevteam.website.page; package buttondevteam.website.page;
import java.io.PrintStream;
import org.apache.commons.io.output.ByteArrayOutputStream;
import com.sun.net.httpserver.*;
import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.website.io.IOHelper; import buttondevteam.website.io.IOHelper;
import buttondevteam.website.io.Response; import buttondevteam.website.io.Response;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import org.apache.commons.io.output.ByteArrayOutputStream;
import java.io.PrintStream;
/** /**
* Add to {@link Main}.Pages * Add using {@link buttondevteam.website.ButtonWebsiteModule#addPage(Page)}
*/ */
public abstract class Page implements HttpHandler { public abstract class Page implements HttpHandler {
public abstract String GetName(); public abstract String GetName();
@ -18,7 +18,7 @@ public abstract class Page implements HttpHandler {
@Override @Override
public final void handle(HttpExchange exchange) { public final void handle(HttpExchange exchange) {
try { try {
exchange.getResponseHeaders().add("Access-Control-Allow-Origin", "https://tbmcplugins.github.io"); exchange.getResponseHeaders().add("Access-Control-Allow-Origin", "https://chromagaming.figytuna.com");
if (exactPage() ? exchange.getRequestURI().getPath().equals("/" + GetName()) : true) if (exactPage() ? exchange.getRequestURI().getPath().equals("/" + GetName()) : true)
IOHelper.SendResponse(handlePage(exchange)); IOHelper.SendResponse(handlePage(exchange));
else { else {