diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 8db9e3d9..bc21bd0d 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1547,7 +1547,8 @@ namespace TShockAPI args.Player.SendMessage("Your new account has been verified, and the /auth system has been turned off."); args.Player.SendMessage("You can always use the /user command to manage players. Do not just delete the auth.lck file."); args.Player.SendMessage("Thankyou for using TShock! http://tshock.co/ & http://github.com/TShock/TShock"); - FileTools.CreateFile(TShock.SavePath + "auth.lck"); + FileTools.CreateFile(Path.Combine(TShock.SavePath, "auth.lck")); + System.IO.File.Delete(Path.Combine(TShock.SavePath + "authcode.txt")); TShock.AuthToken = 0; } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 58187a9c..e4495d32 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -248,13 +248,26 @@ namespace TShockAPI public static int AuthToken = -1; private void OnPostInit() { - if (!File.Exists(Path.Combine(SavePath, "auth.lck"))) + if (!File.Exists(Path.Combine(SavePath, "auth.lck")) && !File.Exists(Path.Combine(SavePath, "authcode.txt"))) { var r = new Random((int)DateTime.Now.ToBinary()); AuthToken = r.Next(100000, 10000000); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("TShock Notice: To become SuperAdmin, join the game and type /auth " + AuthToken); - Console.WriteLine("This token will display until disabled by verification."); + Console.WriteLine("This token will display until disabled by verification. (/auth-verify)"); + Console.ForegroundColor = ConsoleColor.Gray; + TextWriter tw = new StreamWriter(Path.Combine(SavePath, "authcode.txt")); + tw.WriteLine(AuthToken); + tw.Close(); + } else if (File.Exists(Path.Combine(SavePath, "authcode.txt"))) + { + TextReader tr = new StreamReader(Path.Combine(SavePath, "authcode.txt")); + AuthToken = Convert.ToInt32(tr.ReadLine()); + tr.Close(); + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("TShock Notice: authcode.txt is still present, and the AuthToken located in that file will be used."); + Console.WriteLine("To become superadmin, join the game and type /auth " + AuthToken); + Console.WriteLine("This token will display until disabled by verification. (/auth-verify)"); Console.ForegroundColor = ConsoleColor.Gray; } else {