Selaa lähdekoodia

Fix setup page& error display

George Baugh 2 vuotta sitten
vanhempi
sitoutus
65ae6fc645

+ 10 - 7
lib/Trog/Routes/HTML.pm

@@ -412,13 +412,15 @@ One time setup page; should only display to the first user to visit the site whi
 
 sub setup ($query) {
     File::Touch::touch("config/setup");
-    return finish_render(
-        'notconfigured.tx',
-        {
+    Trog::Renderer->render(
+        template => 'notconfigured.tx',
+        data => {
             title       => 'tCMS Requires Setup to Continue...',
-            stylesheets => ['notconfigured.css'],
-            scheme      => $query->{scheme},
-        }
+            stylesheets => _build_themed_styles(['notconfigured.css']),
+            %$query,
+        },
+        contenttype => 'text/html',
+        code => 200,
     );
 }
 
@@ -464,7 +466,7 @@ sub login ($query) {
     # Note to future me -- this user value is overwritten explicitly in server.psgi.
     # If that ever changes, you will die
     $query->{to} //= $query->{route};
-    $query->{to} = '/config' if $query->{to} eq '/login';
+    $query->{to} = '/config' if List::Util::any { $query->{to} eq $_ } qw{/login /logout};
     if ( $query->{user} ) {
         DEBUG("Login by $query->{user}, redirecting to $query->{to}");
         return see_also( $query->{to} );
@@ -515,6 +517,7 @@ sub login ($query) {
             btnmsg      => $btnmsg,
             stylesheets => _build_themed_styles([qw{login.css}]),
             theme_dir   => $Trog::Themes::td,
+            has_users   => $hasusers,
             %$query,
         },
         headers     => $headers,

+ 5 - 2
www/templates/html/jsalert.tx

@@ -27,12 +27,15 @@
         border-radius: .75rem;
         border-color: rgba(255,0,0,.75);
         padding: 1rem;
+        margin-top: 3rem;
+        position: fixed;
+        width:95%;
     }
     .alert-danger {
-        background-color: rgba(255,0,0,.25);
+        background-color: rgba(100,0,0,.95);
     }
     .alert-success {
-        background-color: rgba(0,255,0,.25);
+        background-color: rgba(0,255,0,.95);
     }
 </style>
 

+ 2 - 0
www/templates/html/login.tx

@@ -20,12 +20,14 @@
         <input required name="password" id="password" placeholder="hunter2" value="" type="password"></input>
       </div>
       <br />
+: if ($has_users) {
       TOTP 2FA code (ignore unless enabled)<br />
       <div class="input-group">
         <label for="token">🔒</label>
         <input name="token" id="token" placeholder="7779311" value="" type="password"></input>
       </div>
       <br />
+: }
       <input type="submit" id="maximumGo" value="<: $btnmsg :>"></input>
     </form>
 </div>

+ 2 - 0
www/templates/html/notconfigured.tx

@@ -1,3 +1,4 @@
+: include 'components/header.tx';
 <nav>
     <strong>tCMS Initial Setup</strong>
 </nav>
@@ -19,3 +20,4 @@
         Please <a href="/login?to=/config" alt="Login">Log In</a> and Configure tCMS.
     </p>
 </section>
+: include 'components/footer.tx';