Added Registered field to user db.
Set all those time based fields to use UtcNow, sortable
This commit is contained in:
parent
b8fdb6467c
commit
038b2c027d
3 changed files with 12 additions and 6 deletions
|
|
@ -124,7 +124,7 @@ namespace TShockAPI.DB
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return database.Query("INSERT INTO Bans (IP, Name, Reason, BanningUser, Date, Expiration) VALUES (@0, @1, @2, @3, @4, @5);", ip, name, reason, banner, DateTime.Now.ToString("G"), expiration) != 0;
|
return database.Query("INSERT INTO Bans (IP, Name, Reason, BanningUser, Date, Expiration) VALUES (@0, @1, @2, @3, @4, @5);", ip, name, reason, banner, DateTime.UtcNow.ToString("s"), expiration) != 0;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.CodeDom.Compiler;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -38,6 +39,7 @@ namespace TShockAPI.DB
|
||||||
new SqlColumn("Username", MySqlDbType.VarChar, 32) {Unique = true},
|
new SqlColumn("Username", MySqlDbType.VarChar, 32) {Unique = true},
|
||||||
new SqlColumn("Password", MySqlDbType.VarChar, 128),
|
new SqlColumn("Password", MySqlDbType.VarChar, 128),
|
||||||
new SqlColumn("Usergroup", MySqlDbType.Text),
|
new SqlColumn("Usergroup", MySqlDbType.Text),
|
||||||
|
new SqlColumn("Registered", MySqlDbType.Text),
|
||||||
new SqlColumn("LastAccessed", MySqlDbType.Text),
|
new SqlColumn("LastAccessed", MySqlDbType.Text),
|
||||||
new SqlColumn("KnownIPs", MySqlDbType.Text)
|
new SqlColumn("KnownIPs", MySqlDbType.Text)
|
||||||
);
|
);
|
||||||
|
|
@ -60,8 +62,8 @@ namespace TShockAPI.DB
|
||||||
int ret;
|
int ret;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ret = database.Query("INSERT INTO Users (Username, Password, UserGroup) VALUES (@0, @1, @2);", user.Name,
|
ret = database.Query("INSERT INTO Users (Username, Password, UserGroup, Registered) VALUES (@0, @1, @2, @3);", user.Name,
|
||||||
TShock.Utils.HashPassword(user.Password), user.Group);
|
TShock.Utils.HashPassword(user.Password), user.Group, DateTime.UtcNow.ToString("s"));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -146,7 +148,7 @@ namespace TShockAPI.DB
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (database.Query("UPDATE Users SET LastAccessed = @0, KnownIps = @1 WHERE Username = @2;", DateTime.Now.ToString("G"), user.KnownIps, user.Name) == 0)
|
if (database.Query("UPDATE Users SET LastAccessed = @0, KnownIps = @1 WHERE Username = @2;", DateTime.UtcNow.ToString("s"), user.KnownIps, user.Name) == 0)
|
||||||
throw new UserNotExistException(user.Name);
|
throw new UserNotExistException(user.Name);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -268,6 +270,7 @@ namespace TShockAPI.DB
|
||||||
user.Group = result.Get<string>("Usergroup");
|
user.Group = result.Get<string>("Usergroup");
|
||||||
user.Password = result.Get<string>("Password");
|
user.Password = result.Get<string>("Password");
|
||||||
user.Name = result.Get<string>("Username");
|
user.Name = result.Get<string>("Username");
|
||||||
|
user.Registered = result.Get<string>("Registered");
|
||||||
user.LastAccessed = result.Get<string>("LastAccessed");
|
user.LastAccessed = result.Get<string>("LastAccessed");
|
||||||
user.KnownIps = result.Get<string>("KnownIps");
|
user.KnownIps = result.Get<string>("KnownIps");
|
||||||
return user;
|
return user;
|
||||||
|
|
@ -280,14 +283,16 @@ namespace TShockAPI.DB
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string Group { get; set; }
|
public string Group { get; set; }
|
||||||
|
public string Registered { get; set; }
|
||||||
public string LastAccessed { get; set; }
|
public string LastAccessed { get; set; }
|
||||||
public string KnownIps { get; set; }
|
public string KnownIps { get; set; }
|
||||||
|
|
||||||
public User(string name, string pass, string group, string last, string known)
|
public User(string name, string pass, string group, string registered, string last, string known)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Password = pass;
|
Password = pass;
|
||||||
Group = group;
|
Group = group;
|
||||||
|
Registered = registered;
|
||||||
LastAccessed = last;
|
LastAccessed = last;
|
||||||
KnownIps = known;
|
KnownIps = known;
|
||||||
}
|
}
|
||||||
|
|
@ -297,6 +302,7 @@ namespace TShockAPI.DB
|
||||||
Name = "";
|
Name = "";
|
||||||
Password = "";
|
Password = "";
|
||||||
Group = "";
|
Group = "";
|
||||||
|
Registered = "";
|
||||||
LastAccessed = "";
|
LastAccessed = "";
|
||||||
KnownIps = "";
|
KnownIps = "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ namespace TShockAPI
|
||||||
return RestMissingParam("password");
|
return RestMissingParam("password");
|
||||||
|
|
||||||
// NOTE: ip can be blank
|
// NOTE: ip can be blank
|
||||||
User user = new User(username, password, group, "", "");
|
User user = new User(username, password, group, "", "", "");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TShock.Users.AddUser(user);
|
TShock.Users.AddUser(user);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue