First attempt at getting a little meta data on the client. Included a value for peppering all password hashing functions.
This commit is contained in:
@@ -84,15 +84,17 @@ namespace SecureCore.Services
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetUserSessionToken(int userId, string sessionToken, DateTime expirationDate)
|
||||
public static void SetUserSessionToken(int userId, string sessionToken, DateTime expirationDate, string userAgent, string ipAddress)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
using (var command = new SqlCommand("INSERT INTO [Session]([Session Token], [Expiration Date], [User ID]) VALUES (@SessionToken, @ExpirationDate, @UserKey)", connection))
|
||||
using (var command = new SqlCommand("INSERT INTO [Session]([Session Token], [Expiration Date], [User ID], [User Agent], [IP Address]) VALUES (@SessionToken, @ExpirationDate, @UserKey, @UserAgent, @IpAddress)", connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("SessionToken", sessionToken);
|
||||
command.Parameters.AddWithValue("ExpirationDate", expirationDate);
|
||||
command.Parameters.AddWithValue("UserKey", userId);
|
||||
command.Parameters.AddWithValue("UserAgent", userAgent);
|
||||
command.Parameters.AddWithValue("IpAddress", ipAddress);
|
||||
|
||||
connection.Open();
|
||||
|
||||
@@ -101,7 +103,7 @@ namespace SecureCore.Services
|
||||
}
|
||||
}
|
||||
|
||||
public static int RegisterNewUser(string userName, string email, string passwordHash, string saltHash, string sessionToken, DateTime expirationDate)
|
||||
public static int RegisterNewUser(string userName, string email, string passwordHash, string saltHash, string sessionToken, DateTime expirationDate, string userAgent, string ipAddress)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
@@ -113,6 +115,8 @@ namespace SecureCore.Services
|
||||
command.Parameters.AddWithValue("Salt", saltHash);
|
||||
command.Parameters.AddWithValue("SessionToken", sessionToken);
|
||||
command.Parameters.AddWithValue("ExpirationDate", expirationDate);
|
||||
command.Parameters.AddWithValue("UserAgent", userAgent);
|
||||
command.Parameters.AddWithValue("IpAddress", ipAddress);
|
||||
|
||||
connection.Open();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user