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

View File

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

View File

@@ -1,5 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<script src="/api/v1.1/System/VersionFile"></script> <script src="/api/v1.1/System/VersionFile"></script>
@@ -40,8 +41,10 @@
} }
</script> </script>
</head> </head>
<body> <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 id="bgImage_Opacity"></div>
</div> </div>
@@ -52,7 +55,9 @@
<div id="loginwindow_header_label" style="display: block; text-align: center;">Gaseous Games</div> <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> </div>
<div class="loginwindow" id="first_newadmin" style="display: none;"> <div class="loginwindow" id="first_newadmin" style="display: none;">
@@ -67,15 +72,18 @@
</tr> </tr>
<tr> <tr>
<th>Email</th> <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>
<tr> <tr>
<th>New Password</th> <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>
<tr> <tr>
<th>Confirm Password</th> <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>
<tr> <tr>
<td colspan="2" id="login_passwordnotice">&nbsp;</td> <td colspan="2" id="login_passwordnotice">&nbsp;</td>
@@ -85,7 +93,9 @@
</tr> </tr>
<tr> <tr>
<td colspan="2" style="padding-top: 20px;"> <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> </td>
</tr> </tr>
</table> </table>
@@ -94,12 +104,14 @@
</div> </div>
<div id="settings_photocredit"> <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> </div>
<script type="text/javascript"> <script type="text/javascript">
// redirect if first run status != 0 as 0 indicates that first run needs to be run // 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("/"); window.location.replace("/");
} }