Merge pull request #8 from Moonlight-Panel/main
Updated discord bot branch
This commit is contained in:
commit
6eed362c04
13 changed files with 1125 additions and 28 deletions
|
@ -1,11 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EfCoreCommonOptions">
|
||||
<option name="migrationsToStartupProjects">
|
||||
<map>
|
||||
<entry key="16141d00-a997-4ba6-b0dc-af6f4712613a" value="16141d00-a997-4ba6-b0dc-af6f4712613a" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="solutionLevelOptions">
|
||||
<map>
|
||||
<entry key="migrationsProject" value="16141d00-a997-4ba6-b0dc-af6f4712613a" />
|
||||
<entry key="startupProject" value="16141d00-a997-4ba6-b0dc-af6f4712613a" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="startupToMigrationsProjects">
|
||||
<map>
|
||||
<entry key="16141d00-a997-4ba6-b0dc-af6f4712613a" value="16141d00-a997-4ba6-b0dc-af6f4712613a" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -30,8 +30,6 @@ public class User
|
|||
|
||||
// Discord
|
||||
public long DiscordId { get; set; } = -1;
|
||||
public string DiscordUsername { get; set; } = "";
|
||||
public string DiscordDiscriminator { get; set; } = "";
|
||||
|
||||
// Date stuff
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
|
1058
Moonlight/App/Database/Migrations/20230324164853_RemovedDiscordUsernameAndDiscriminator.Designer.cs
generated
Normal file
1058
Moonlight/App/Database/Migrations/20230324164853_RemovedDiscordUsernameAndDiscriminator.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 RemovedDiscordUsernameAndDiscriminator : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DiscordDiscriminator",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DiscordUsername",
|
||||
table: "Users");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "DiscordDiscriminator",
|
||||
table: "Users",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "DiscordUsername",
|
||||
table: "Users",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -723,17 +723,9 @@ namespace Moonlight.App.Database.Migrations
|
|||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("DiscordDiscriminator")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<long>("DiscordId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("DiscordUsername")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Moonlight.App.Exceptions;
|
||||
using Moonlight.App.Helpers;
|
||||
using Moonlight.App.Models.Misc;
|
||||
using Moonlight.App.Repositories;
|
||||
using Moonlight.App.Services;
|
||||
using Moonlight.App.Services.OAuth2;
|
||||
|
@ -104,6 +105,14 @@ public class OAuth2Controller : Controller
|
|||
userData.FirstName,
|
||||
userData.LastName
|
||||
);
|
||||
|
||||
var newUser = UserRepository
|
||||
.Get()
|
||||
.First(x => x.Email == userData.Email);
|
||||
|
||||
newUser.Status = UserStatus.DataPending;
|
||||
|
||||
UserRepository.Update(newUser);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -8,5 +8,6 @@ public enum UserStatus
|
|||
VerifyFailed,
|
||||
Warned,
|
||||
Banned,
|
||||
Disabled
|
||||
Disabled,
|
||||
DataPending
|
||||
}
|
|
@ -3,6 +3,7 @@ using Logging.Net;
|
|||
using Moonlight.App.Database.Entities;
|
||||
using Moonlight.App.Exceptions;
|
||||
using Moonlight.App.Models.Google.Requests;
|
||||
using Moonlight.App.Models.Misc;
|
||||
using RestSharp;
|
||||
|
||||
namespace Moonlight.App.Services.OAuth2;
|
||||
|
@ -112,8 +113,10 @@ public class DiscordOAuth2Service
|
|||
return new User()
|
||||
{
|
||||
Email = getData.GetValue<string>("email"),
|
||||
FirstName = getData.GetValue<string>("username"),
|
||||
LastName = getData.GetValue<string>("discriminator")
|
||||
FirstName = "User",
|
||||
LastName = "User",
|
||||
DiscordId = getData.GetValue<long>("id"),
|
||||
Status = UserStatus.DataPending
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -69,9 +69,7 @@ public class UserService
|
|||
State = "",
|
||||
Status = UserStatus.Unverified,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
DiscordDiscriminator = "",
|
||||
DiscordId = -1,
|
||||
DiscordUsername = "",
|
||||
TotpEnabled = false,
|
||||
TotpSecret = "",
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
|
|
|
@ -134,18 +134,6 @@
|
|||
</label>
|
||||
<input @bind="User.DiscordId" type="number" class="form-control">
|
||||
</div>
|
||||
<div class="mb-10">
|
||||
<label class="form-label">
|
||||
<TL>Discord username</TL>
|
||||
</label>
|
||||
<input @bind="User.DiscordUsername" type="text" class="form-control">
|
||||
</div>
|
||||
<div class="mb-10">
|
||||
<label class="form-label">
|
||||
<TL>Discord discriminator</TL>
|
||||
</label>
|
||||
<input @bind="User.DiscordDiscriminator" type="text" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -186,7 +186,7 @@ else
|
|||
<TL>Discord</TL>
|
||||
</label>
|
||||
<div class="col-lg-8">
|
||||
<span class="fw-bold fs-6 text-gray-800">@(User.DiscordUsername)#@(User.DiscordDiscriminator)</span>
|
||||
<span class="fw-bold fs-6 text-gray-800">@* TODO: Implement discord fetching here *@</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="separator my-4"></div>
|
||||
|
|
Loading…
Reference in a new issue