Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability for admins to ask users for verification codes #633

Merged
merged 2 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Refresh.GameServer/CommandLineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ private class Options

[Option("mark-all-reuploads", HelpText = "Marks all levels uploaded by a user as re-uploaded. Username or Email options are required if this is set.")]
public bool MarkAllReuploads { get; set; }

[Option("ask-for-verification", HelpText = "Sends a verification code to confirm a user's identity over an untrusted channel. Username or Email options are required if this is set.")]
public bool AskUserForVerification { get; set; }
}

internal void StartWithArgs(string[] args)
Expand Down Expand Up @@ -203,5 +206,15 @@ private void StartWithOptions(Options options)
GameUser user = this.GetUserOrFail(options);
this._server.MarkAllReuploads(user);
}
else if (options.AskUserForVerification)
{
GameUser user = this.GetUserOrFail(options);
string code = this._server.AskUserForVerification(user);
Console.WriteLine($"The code has been sent to {user.Username}'s notifications.");
Console.WriteLine();
Console.WriteLine($"\tCode: {code}");
Console.WriteLine();
Console.WriteLine("If the user does not reply to you with *exactly* this code, assume the worst.");
}
}
}
15 changes: 15 additions & 0 deletions Refresh.GameServer/RefreshGameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Bunkum.HealthChecks.RealmDatabase;
using Bunkum.Protocols.Http;
using Refresh.Common;
using Refresh.Common.Verification;
using Refresh.GameServer.Authentication;
using Refresh.GameServer.Configuration;
using Refresh.GameServer.Database;
Expand Down Expand Up @@ -261,6 +262,20 @@ public void MarkAllReuploads(GameUser user)
context.MarkAllReuploads(user);
}

public string AskUserForVerification(GameUser user)
{
using GameDatabaseContext context = this.GetContext();
string code = CodeHelper.GenerateDigitCode();

string text = $"An admin is requesting a code to verify that you currently have access to your account. " +
$"Please share the code '{code}' with the admin you're currently speaking with. " +
"If you're not in contact with any such staff member, please report this immediately.";

context.AddNotification("Admin Verification Request (Action Required)", text, user, "shield");

return code;
}

public override void Dispose()
{
this._databaseProvider.Dispose();
Expand Down
Loading