Merge pull request #207 from Moonlight-Panel/AddIpLogs
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 Subscription? CurrentSubscription { get; set; } = null;
|
||||||
public DateTime SubscriptionSince { get; set; } = DateTime.Now;
|
public DateTime SubscriptionSince { get; set; } = DateTime.Now;
|
||||||
public int SubscriptionDuration { get; set; }
|
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")
|
b.Property<bool>("HasRated")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<string>("LastIp")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
b.Property<string>("LastName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
@@ -780,6 +784,10 @@ namespace Moonlight.App.Database.Migrations
|
|||||||
b.Property<int>("Rating")
|
b.Property<int>("Rating")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("RegisterIp")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<string>("ServerListLayoutJson")
|
b.Property<string>("ServerListLayoutJson")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|||||||
@@ -119,6 +119,10 @@ public class IdentityService
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
UserCache = user;
|
UserCache = user;
|
||||||
|
|
||||||
|
user.LastIp = GetIp();
|
||||||
|
UserRepository.Update(user);
|
||||||
|
|
||||||
return UserCache;
|
return UserCache;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ public class UserService
|
|||||||
TotpEnabled = false,
|
TotpEnabled = false,
|
||||||
TotpSecret = "",
|
TotpSecret = "",
|
||||||
UpdatedAt = DateTimeService.GetCurrent(),
|
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 => {});
|
await MailService.SendMail(user!, "register", values => {});
|
||||||
|
|||||||
@@ -29,9 +29,15 @@ else
|
|||||||
</div>
|
</div>
|
||||||
<div class="card card-body mb-5">
|
<div class="card card-body mb-5">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a class="btn btn-primary" href="/admin/users/edit/@(User.Id)"><TL>Edit</TL></a>
|
<a class="btn btn-primary" href="/admin/users/edit/@(User.Id)">
|
||||||
<a class="btn btn-secondary" href="/admin/users"><TL>Back to list</TL></a>
|
<TL>Edit</TL>
|
||||||
<a class="btn btn-primary" href="/admin/support/view/@(User.Id)"><TL>Open support</TL></a>
|
</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>
|
</div>
|
||||||
<div class="card card-xl-stretch mb-5">
|
<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>
|
<span class="fw-bold fs-6 text-gray-800">@(Formatter.FormatDate(User.CreatedAt))</span>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user