Fix for first time start where new users weren't offered the opportunity to create a new account (#372)

This commit is contained in:
Michael Green
2024-06-25 08:57:56 +10:00
committed by GitHub
parent cebab38dd6
commit 3897ed65ef
3 changed files with 86 additions and 53 deletions

View File

@@ -70,7 +70,8 @@ namespace gaseous_server.Controllers
[HttpGet]
[Route("Version")]
[ProducesResponseType(StatusCodes.Status200OK)]
public Version GetSystemVersion() {
public Version GetSystemVersion()
{
return Assembly.GetExecutingAssembly().GetName().Version;
}
@@ -80,7 +81,8 @@ namespace gaseous_server.Controllers
[Route("VersionFile")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
public FileContentResult GetSystemVersionAsFile() {
public FileContentResult GetSystemVersionAsFile()
{
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
// get age ratings dictionary
@@ -98,14 +100,17 @@ namespace gaseous_server.Controllers
string ver = "var AppVersion = \"" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\";" + Environment.NewLine +
"var DBSchemaVersion = \"" + db.GetDatabaseSchemaVersion() + "\";" + Environment.NewLine +
"var FirstRunStatus = " + Config.ReadSetting<string>("FirstRunStatus", "0") + ";" + Environment.NewLine +
"var AgeRatingBoardsStrings = " + JsonSerializer.Serialize(ClassificationBoardsStrings, new JsonSerializerOptions{
"var FirstRunStatus = \"" + Config.ReadSetting<string>("FirstRunStatus", "0") + "\";" + Environment.NewLine +
"var AgeRatingBoardsStrings = " + JsonSerializer.Serialize(ClassificationBoardsStrings, new JsonSerializerOptions
{
WriteIndented = true
}) + ";" + Environment.NewLine +
"var AgeRatingStrings = " + JsonSerializer.Serialize(AgeRatingsStrings, new JsonSerializerOptions{
"var AgeRatingStrings = " + JsonSerializer.Serialize(AgeRatingsStrings, new JsonSerializerOptions
{
WriteIndented = true
}) + ";" + Environment.NewLine +
"var AgeRatingGroups = " + JsonSerializer.Serialize(AgeGroups.AgeGroupingsFlat, new JsonSerializerOptions{
"var AgeRatingGroups = " + JsonSerializer.Serialize(AgeGroups.AgeGroupingsFlat, new JsonSerializerOptions
{
WriteIndented = true
}) + ";" + Environment.NewLine +
"var emulatorDebugMode = " + Config.ReadSetting<string>("emulatorDebugMode", false.ToString()).ToLower() + ";";
@@ -251,7 +256,8 @@ namespace gaseous_server.Controllers
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult GetSystemSettings()
{
SystemSettingsModel systemSettingsModel = new SystemSettingsModel{
SystemSettingsModel systemSettingsModel = new SystemSettingsModel
{
AlwaysLogToDisk = Config.LoggingConfiguration.AlwaysLogToDisk,
MinimumLogRetentionPeriod = Config.LoggingConfiguration.LogRetention,
EmulatorDebugMode = Boolean.Parse(Config.ReadSetting<string>("emulatorDebugMode", false.ToString()))
@@ -281,7 +287,8 @@ namespace gaseous_server.Controllers
private SystemInfo.PathItem GetDisk(string Path)
{
SystemInfo.PathItem pathItem = new SystemInfo.PathItem {
SystemInfo.PathItem pathItem = new SystemInfo.PathItem
{
LibraryPath = Path,
SpaceUsed = Common.DirSize(new DirectoryInfo(Path)),
SpaceAvailable = new DriveInfo(Path).AvailableFreeSpace,
@@ -293,7 +300,8 @@ namespace gaseous_server.Controllers
public class SystemInfo
{
public Version ApplicationVersion {
public Version ApplicationVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version;
@@ -589,7 +597,8 @@ namespace gaseous_server.Controllers
}
private bool _UserManageable;
public bool UserManageable => _UserManageable;
public int Interval {
public int Interval
{
get
{
return int.Parse(Config.ReadSetting<string>("Interval_" + Task, DefaultInterval.ToString()));

View File

@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="/api/v1.1/System/VersionFile"></script>
@@ -44,6 +45,7 @@
var userProfile;
</script>
</head>
<body>
<!-- Notifications -->
<div id="notifications_target"></div>
@@ -54,7 +56,9 @@
<div id="banner_header">
<div id="bannerButtons">
<div id="banner_user" onclick="showMenu();" class="banner_button dropdown dropbtn">
<img src="/images/user.svg" alt="Account" title="Account" id="banner_user_image" class="banner_button_image" style="position: relative; top: 10px; right: 0px; pointer-events: none;" onclick="showMenu();" />
<img src="/images/user.svg" alt="Account" title="Account" id="banner_user_image"
class="banner_button_image" style="position: relative; top: 10px; right: 0px; pointer-events: none;"
onclick="showMenu();" />
<div id="myDropdown" class="dropdown-content">
<div id="banner_user_roles"></div>
<a href="#" onclick="showDialog('userprofile');">Profile</a>
@@ -63,22 +67,27 @@
</div>
<div id="banner_cog" onclick="window.location.href = '/index.html?page=settings';" class="banner_button">
<img src="/images/settings.svg" alt="Settings" title="Settings" id="banner_system_image" class="banner_button_image" />
<img src="/images/settings.svg" alt="Settings" title="Settings" id="banner_system_image"
class="banner_button_image" />
<span id="banner_system_label">Settings</span>
</div>
<div id="banner_upload" onclick="showDialog('upload');" class="banner_button">
<img src="/images/upload.svg" alt="Upload" title="Upload" id="banner_upload_image" class="banner_button_image" />
<img src="/images/upload.svg" alt="Upload" title="Upload" id="banner_upload_image"
class="banner_button_image" />
<span id="banner_upload_label">Upload</span>
</div>
<div id="banner_collections" onclick="window.location.href = '/index.html?page=collections';" class="banner_button">
<img src="/images/collections.svg" alt="Collections" title="Collections" id="banner_collections_image" class="banner_button_image" />
<div id="banner_collections" onclick="window.location.href = '/index.html?page=collections';"
class="banner_button">
<img src="/images/collections.svg" alt="Collections" title="Collections" id="banner_collections_image"
class="banner_button_image" />
<span id="banner_collections_label">Collections</span>
</div>
<div id="banner_library" onclick="window.location.href = '/index.html';" class="banner_button">
<img src="/images/library.svg" alt="Library" title="Library" id="banner_library_image" class="banner_button_image" />
<img src="/images/library.svg" alt="Library" title="Library" id="banner_library_image"
class="banner_button_image" />
<span id="banner_library_label">Library</span>
</div>
</div>
@@ -97,7 +106,9 @@
<!-- Modal content -->
<div class="modal-content">
<span class="close">&times;</span>
<div><h1 id="modal-heading">Modal heading</h1></div>
<div>
<h1 id="modal-heading">Modal heading</h1>
</div>
<div id="modal-content">Some text in the Modal..</div>
</div>
@@ -118,7 +129,7 @@
var modalVariables = null;
// redirect if first run status = 0
if (FirstRunStatus == 0) {
if (FirstRunStatus == 0 || FirstRunStatus == "0") {
window.location.replace("/pages/first.html");
}
@@ -186,4 +197,5 @@
}
</script>
</body>
</html>

View File

@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="/api/v1.1/System/VersionFile"></script>
@@ -40,8 +41,10 @@
}
</script>
</head>
<body>
<div id="bgImage" style="background-image: url('/images/LoginWallpaper.jpg'); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);">
<div id="bgImage"
style="background-image: url('/images/LoginWallpaper.jpg'); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);">
<div id="bgImage_Opacity"></div>
</div>
@@ -52,7 +55,9 @@
<div id="loginwindow_header_label" style="display: block; text-align: center;">Gaseous Games</div>
<button type="button" value="Get Started" onclick="document.getElementById('first_welcome').style.display = 'none'; document.getElementById('first_newadmin').style.display = '';" class="bigbutton">Get Started</button>
<button type="button" value="Get Started"
onclick="document.getElementById('first_welcome').style.display = 'none'; document.getElementById('first_newadmin').style.display = '';"
class="bigbutton">Get Started</button>
</div>
</div>
<div class="loginwindow" id="first_newadmin" style="display: none;">
@@ -67,15 +72,18 @@
</tr>
<tr>
<th>Email</th>
<td><input type="email" id="login_email" style="width: 95%;" onkeyup="checkPasswordsMatch();" /></td>
<td><input type="email" id="login_email" style="width: 95%;" onkeyup="checkPasswordsMatch();" />
</td>
</tr>
<tr>
<th>New Password</th>
<td><input type="password" id="login_password" style="width: 95%;" onkeyup="checkPasswordsMatch();" /></td>
<td><input type="password" id="login_password" style="width: 95%;"
onkeyup="checkPasswordsMatch();" /></td>
</tr>
<tr>
<th>Confirm Password</th>
<td><input type="password" id="login_confirmpassword" style="width: 95%;" onkeyup="checkPasswordsMatch();" /></td>
<td><input type="password" id="login_confirmpassword" style="width: 95%;"
onkeyup="checkPasswordsMatch();" /></td>
</tr>
<tr>
<td colspan="2" id="login_passwordnotice">&nbsp;</td>
@@ -85,7 +93,9 @@
</tr>
<tr>
<td colspan="2" style="padding-top: 20px;">
<button id="login_createaccount" type="button" value="Create Account" onclick="registerAccount();" disabled="disabled" class="bigbutton">Create Account</button>
<button id="login_createaccount" type="button" value="Create Account"
onclick="registerAccount();" disabled="disabled" class="bigbutton">Create
Account</button>
</td>
</tr>
</table>
@@ -94,12 +104,14 @@
</div>
<div id="settings_photocredit">
Wallpaper by <a href="https://unsplash.com/@spideyjoey" class="romlink">Joey Kwok</a> / <a href="https://unsplash.com/photos/a-room-filled-with-arcade-machines-and-neon-lights-jbIsTd7rdd8" class="romlink">Unsplash</a>
Wallpaper by <a href="https://unsplash.com/@spideyjoey" class="romlink">Joey Kwok</a> / <a
href="https://unsplash.com/photos/a-room-filled-with-arcade-machines-and-neon-lights-jbIsTd7rdd8"
class="romlink">Unsplash</a>
</div>
<script type="text/javascript">
// redirect if first run status != 0 as 0 indicates that first run needs to be run
if (FirstRunStatus != 0) {
if (FirstRunStatus != 0 && FirstRunStatus != "0") {
window.location.replace("/");
}