Registration process for new website
Dieser Commit ist enthalten in:
Ursprung
114fac5bd7
Commit
81bd27cded
@ -71,7 +71,7 @@ public class BungeeCore extends Plugin {
|
||||
new MsgCommand();
|
||||
new RCommand();
|
||||
new PingCommand();
|
||||
new WebpwCommand();
|
||||
new WebregisterCommand();
|
||||
new AlertCommand();
|
||||
new KickCommand();
|
||||
new JoinmeCommand();
|
||||
@ -196,7 +196,6 @@ public class BungeeCore extends Plugin {
|
||||
|
||||
SQL.connect(
|
||||
config.getString("db.url"),
|
||||
config.getString("db.weburl"),
|
||||
config.getString("db.username"),
|
||||
config.getString("db.password")
|
||||
);
|
||||
|
@ -1,33 +0,0 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public class WebpwCommand extends BasicCommand {
|
||||
|
||||
public WebpwCommand() {
|
||||
super("webpw", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(sender instanceof ProxiedPlayer){
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
if(args.length != 2){
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "/webpw [Passwort] [Passwort wiederholen]");
|
||||
return;
|
||||
}else if(!args[0].equals(args[1])){
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDie Passwörter stimmen nicht überein!");
|
||||
return;
|
||||
}else if(args[0].length() < 6){
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDas Passwort muss mindestens 6 Zeichen lang sein!");
|
||||
return;
|
||||
}
|
||||
|
||||
SteamwarUser.get(player.getUniqueId()).setWebpw(args[0]);
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Webpasswort gesetzt!");
|
||||
}
|
||||
}
|
||||
}
|
63
src/de/steamwar/bungeecore/commands/WebregisterCommand.java
Normale Datei
63
src/de/steamwar/bungeecore/commands/WebregisterCommand.java
Normale Datei
@ -0,0 +1,63 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.SWException;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class WebregisterCommand extends BasicCommand {
|
||||
|
||||
public WebregisterCommand() {
|
||||
super("webregister", null, "web");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
if(args.length != 1){
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "/webregister [E-Mail]");
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", player.getName(), args[0]);
|
||||
try {
|
||||
Process regProcess = pb.start();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(regProcess.getInputStream()));
|
||||
String errorLine;
|
||||
boolean error = false;
|
||||
while((errorLine = reader.readLine()) != null){
|
||||
switch(errorLine){
|
||||
case "username_exists":
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu hast bereits einen Webaccount.");
|
||||
break;
|
||||
case "email_exists":
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDie E-Mail hast du bereits für einen anderen Account verwendet...");
|
||||
SWException.log("Bungee", "Duplicate E-Mail", player.getName() + " " + args[0]);
|
||||
break;
|
||||
case "invalid_email":
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c[E-Mail], nicht [Freitext]!");
|
||||
break;
|
||||
default:
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEin interner Fehler ist aufgetreten, bitte wende dich an einen Developer.");
|
||||
SWException.log("Bungee", "Unknown Wordpress User Creation Error", errorLine);
|
||||
}
|
||||
error = true;
|
||||
}
|
||||
|
||||
if(error)
|
||||
return;
|
||||
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§aEine E-Mail zum Setzen des Passworts wurde gesendet.");
|
||||
} catch (IOException e) {
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEin interner Fehler ist aufgetreten, bitte wende dich an einen Developer.");
|
||||
throw new SecurityException("Could not create webaccount", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,20 +10,16 @@ public class SQL {
|
||||
private SQL(){}
|
||||
|
||||
private static Connection con;
|
||||
private static Connection webcon;
|
||||
private static String url;
|
||||
private static String weburl;
|
||||
private static String user;
|
||||
private static String password;
|
||||
|
||||
public static void connect(String url, String weburl, String user, String password) {
|
||||
public static void connect(String url, String user, String password) {
|
||||
SQL.url = url;
|
||||
SQL.weburl = weburl;
|
||||
SQL.user = user;
|
||||
SQL.password = password;
|
||||
try {
|
||||
con = DriverManager.getConnection(url + "?autoreconnect=true", user, password);
|
||||
webcon = DriverManager.getConnection(weburl + "?autoreconnect=true", user, password);
|
||||
}catch (SQLException e) {
|
||||
ProxyServer.getInstance().stop();
|
||||
throw new SecurityException("Could not start SQL-Exception", e);
|
||||
@ -34,8 +30,6 @@ public class SQL {
|
||||
try {
|
||||
if(con != null)
|
||||
con.close();
|
||||
if(webcon != null)
|
||||
webcon.close();
|
||||
}catch (SQLException e) {
|
||||
BungeeCore.log("Could not close SQL-Connection", e);
|
||||
}
|
||||
@ -54,19 +48,6 @@ public class SQL {
|
||||
}
|
||||
}
|
||||
|
||||
static void webupdate(String qry, Object... objects) {
|
||||
try {
|
||||
prepare(webcon, qry, objects).executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
sqlException();
|
||||
try {
|
||||
prepare(webcon, qry, objects).executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
throw new SecurityException("Could not execute update statement", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ResultSet select(String qry, Object... objects){
|
||||
try{
|
||||
return prepare(con, qry, objects).executeQuery();
|
||||
@ -90,6 +71,6 @@ public class SQL {
|
||||
|
||||
private static void sqlException(){
|
||||
close();
|
||||
connect(url, weburl, user, password);
|
||||
connect(url, user, password);
|
||||
}
|
||||
}
|
||||
|
@ -94,10 +94,6 @@ public class SteamwarUser {
|
||||
usersByUUID.clear();
|
||||
}
|
||||
|
||||
public void setWebpw(String password){
|
||||
SQL.webupdate("INSERT INTO User (UID, WebPassword) VALUES (?, password(?)) ON DUPLICATE KEY UPDATE WebPassword = VALUES(WebPassword)", id, password);
|
||||
}
|
||||
|
||||
public void setTeam(int team){
|
||||
this.team = team;
|
||||
SQL.update("Update UserData SET Team = ? WHERE id = ?", team, id);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren