Added ip log for register and last visit
This commit is contained in:
@@ -53,4 +53,8 @@ public class User
|
||||
public Subscription? CurrentSubscription { get; set; } = null;
|
||||
public DateTime SubscriptionSince { get; set; } = DateTime.Now;
|
||||
public int SubscriptionDuration { get; set; }
|
||||
|
||||
// Ip logs
|
||||
public string RegisterIp { get; set; } = "";
|
||||
public string LastIp { get; set; } = "";
|
||||
}
|
||||
1088
Moonlight/App/Database/Migrations/20230703175432_AddedIpLogsForUser.Designer.cs
generated
Normal file
1088
Moonlight/App/Database/Migrations/20230703175432_AddedIpLogsForUser.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Moonlight.App.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddedIpLogsForUser : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "LastIp",
|
||||
table: "Users",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "RegisterIp",
|
||||
table: "Users",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastIp",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RegisterIp",
|
||||
table: "Users");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -766,6 +766,10 @@ namespace Moonlight.App.Database.Migrations
|
||||
b.Property<bool>("HasRated")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("LastIp")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
@@ -780,6 +784,10 @@ namespace Moonlight.App.Database.Migrations
|
||||
b.Property<int>("Rating")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RegisterIp")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ServerListLayoutJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -119,6 +119,10 @@ public class IdentityService
|
||||
return null;
|
||||
|
||||
UserCache = user;
|
||||
|
||||
user.LastIp = GetIp();
|
||||
UserRepository.Update(user);
|
||||
|
||||
return UserCache;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -72,7 +72,9 @@ public class UserService
|
||||
TotpEnabled = false,
|
||||
TotpSecret = "",
|
||||
UpdatedAt = DateTimeService.GetCurrent(),
|
||||
TokenValidTime = DateTimeService.GetCurrent().AddDays(-5)
|
||||
TokenValidTime = DateTimeService.GetCurrent().AddDays(-5),
|
||||
LastIp = IdentityService.GetIp(),
|
||||
RegisterIp = IdentityService.GetIp()
|
||||
});
|
||||
|
||||
await MailService.SendMail(user!, "register", values => {});
|
||||
|
||||
@@ -29,9 +29,15 @@ else
|
||||
</div>
|
||||
<div class="card card-body mb-5">
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-primary" href="/admin/users/edit/@(User.Id)"><TL>Edit</TL></a>
|
||||
<a class="btn btn-secondary" href="/admin/users"><TL>Back to list</TL></a>
|
||||
<a class="btn btn-primary" href="/admin/support/view/@(User.Id)"><TL>Open support</TL></a>
|
||||
<a class="btn btn-primary" href="/admin/users/edit/@(User.Id)">
|
||||
<TL>Edit</TL>
|
||||
</a>
|
||||
<a class="btn btn-secondary" href="/admin/users">
|
||||
<TL>Back to list</TL>
|
||||
</a>
|
||||
<a class="btn btn-primary" href="/admin/support/view/@(User.Id)">
|
||||
<TL>Open support</TL>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card card-xl-stretch mb-5">
|
||||
@@ -209,6 +215,24 @@ else
|
||||
<span class="fw-bold fs-6 text-gray-800">@(Formatter.FormatDate(User.CreatedAt))</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="separator my-4"></div>
|
||||
<div class="row">
|
||||
<label class="col-lg-4 fw-semibold text-muted">
|
||||
<TL>Register ip</TL>
|
||||
</label>
|
||||
<div class="col-lg-8">
|
||||
<span class="fw-bold fs-6 text-gray-800">@(User.RegisterIp)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="separator my-4"></div>
|
||||
<div class="row">
|
||||
<label class="col-lg-4 fw-semibold text-muted">
|
||||
<TL>Last ip</TL>
|
||||
</label>
|
||||
<div class="col-lg-8">
|
||||
<span class="fw-bold fs-6 text-gray-800">@(User.LastIp)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user