mirror of
				https://github.com/billz/raspap-webgui.git
				synced 2025-03-01 10:31:47 +00:00 
			
		
		
		
	Initial commit
This commit is contained in:
		
							
								
								
									
										38
									
								
								includes/login.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								includes/login.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| <?php | ||||
|  | ||||
| require_once 'includes/config.php'; | ||||
| require_once 'includes/functions.php'; | ||||
|  | ||||
| /** | ||||
|  * Handler for administrative user login | ||||
|  */ | ||||
| function DisplayLogin() | ||||
| { | ||||
|     // initialize auth object | ||||
|     $auth = new \RaspAP\Auth\HTTPAuth; | ||||
|  | ||||
|     // handle page action | ||||
|     if (RASPI_AUTH_ENABLED) { | ||||
|         if (isset($_POST['login-auth'])) { | ||||
|             // authenticate user | ||||
|             $username = $_POST['username']; | ||||
|             $password = $_POST['password']; | ||||
|             $redirectUrl = $_POST['redirect-url']; | ||||
|             if ($auth->login($username, $password)) { | ||||
|                 $config = $auth->getAuthConfig(); | ||||
|                 header('Location: ' . $redirectUrl); | ||||
|                 die(); | ||||
|             } else { | ||||
|                 $status = "Login failed"; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     echo renderTemplate( | ||||
|         "login", compact( | ||||
|             "status", | ||||
|             "redirectUrl" | ||||
|         ) | ||||
|     ); | ||||
| } | ||||
|  | ||||
							
								
								
									
										42
									
								
								templates/login.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								templates/login.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
|  | ||||
| <!-- fullscreen modal --> | ||||
| <div class="modal" id="modal-admin-login" data-bs-backdrop="static" data-bs-keyboard="false" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true"> | ||||
|   <div class="modal-dialog modal-fullscreen" role="document"> | ||||
|     <div class="modal-content"> | ||||
|       <div class="modal-body"> | ||||
|         <div class="row h-100 justify-content-center align-items-center"> | ||||
|           <div class="col-12"> | ||||
|             <!-- branding --> | ||||
|             <div class="text-center mb-3"> | ||||
|               <img src="app/img/raspAP-logo.php" class="navbar-logo" alt="RaspAP logo" class="img-fluid" style="max-width: 100px;"> | ||||
|               <h2 class="login-brand">RaspAP</h2> | ||||
|               <div class="mt-2 admin-login"><?php echo _("Administrator login") ?></div> | ||||
|               <div class="text-center text-danger mt-1 mb-3"><?php echo $status ?></div> | ||||
|             </div> | ||||
|             <div class="text-center mb-4"> | ||||
|               <form id="admin-login-form" action="login" method="POST" class="needs-validation" novalidate> | ||||
|               <?php echo CSRFTokenFieldTag() ?> | ||||
|                 <div class="form-group"> | ||||
|                   <input type="hidden" name="login-auth"> | ||||
|                   <input type="hidden" id="redirect-url" name="redirect-url" value="<?php echo htmlspecialchars($redirectUrl, ENT_QUOTES, 'UTF-8'); ?>"> | ||||
|                   <input type="text" class="form-control" id="username" name="username" placeholder="<?php echo _("Username") ?>" required> | ||||
|                 </div> | ||||
|                 <div class="mt-2"> | ||||
|                   <div class="input-group has-validation"> | ||||
|                     <input type="password" class="form-control rounded-start border-end-0 no-right-radius" id="password" name="password" placeholder="<?php echo _("Password") ?>" required> | ||||
|                     <button class="btn bg-white btn-passwd-append border-start-0 js-toggle-password" type="button" id="passwd-toggle" data-bs-target="[name=password]" data-toggle-with="fas fa-eye-slash text-secondary text-opacity-50"> | ||||
|                       <i class="fas fa-eye text-secondary text-opacity-50"></i> | ||||
|                     </button> | ||||
|                   </div> | ||||
|  | ||||
|                 </div> | ||||
|                 <button type="submit" class="btn btn-outline btn-admin-login rounded-pill w-75 mt-4"><?php echo _("Login") ?></button> | ||||
|                 <div class="small mt-2"><a href="https://docs.raspap.com/authentication/#restoring-defaults" target="_blank"><?php echo _("Forgot password") ?></a></div> | ||||
|               </form> | ||||
|             </div> | ||||
|           </div><!-- /.col --> | ||||
|         </div><!-- /.row --> | ||||
|       </div><!-- /.modal-body --> | ||||
|     </div><!-- /.modal-content --> | ||||
|   </div><!-- /.modal-dialog --> | ||||
| </div> | ||||
		Reference in New Issue
	
	Block a user