mirror of
				https://github.com/billz/raspap-webgui.git
				synced 2025-03-01 10:31:47 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			39 lines
		
	
	
		
			892 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			892 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?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"
 | |
|         )
 | |
|     );
 | |
| }
 | |
| 
 |