Login to Joomla from External Site
https://stackoverflow.com/questions/21644903/external-login-verification-in-joomla
https://stackoverflow.com/questions/2075335/how-to-log-into-joomla-through-an-external-script
| <?php | |
| // https://dominio.joomla.com/external-login.html | |
| // /datadrive/www/html/joomla/components/com_jumi/files/external-login.php | |
| // error_reporting(E_ALL ^ E_STRICT); | |
| // ini_set('display_errors', 1); | |
| $app = JFactory::getApplication('site'); | |
| $session = JFactory::getSession(); | |
| $credentials = array(); | |
| $credentials['username'] = $app->input->post->get('username', '', 'string'); | |
| $credentials['password'] = $app->input->post->get('password', '', 'string'); | |
| if (true === $app->login($credentials)) | |
| { | |
| $user = JFactory::getUser(); | |
| // $redirecturl = 'mis-cursos.html'; | |
| $redirecturl = 'index.php'; | |
| $app->redirect($redirecturl); | |
| } | |
| else | |
| { | |
| ?> | |
| <div class="alert alert-danger"> | |
| <strong>Acceso Denegado</strong> | |
| </div> | |
| <?php | |
| } |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>External login · Joomla</title> | |
| <link href="https://getbootstrap.com/docs/5.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous"> | |
| <link href="https://getbootstrap.com/docs/5.0/examples/sign-in/signin.css" rel="stylesheet"> | |
| </head> | |
| <body class="text-center"> | |
| <main class="form-signin"> | |
| <form action="https://dominio.joomla.com/external-login.html" method="post"> | |
| <img class="mb-4" src="https://cdn.joomla.org/images/Joomla_logo.png" alt="Joomla CMS" width="40" height="40"> | |
| <label for="username" class="visually-hidden">Username</label> | |
| <input type="text" id="username" name="username" class="form-control" placeholder="Username" required> | |
| <label for="password" class="visually-hidden">Password</label> | |
| <input type="password" id="password" name="password" class="form-control" placeholder="Password" required> | |
| <button class="w-100 btn btn-lg btn-primary" type="submit">Log in</button> | |
| </form> | |
| </main> | |
| </body> | |
| </html> |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>External login · Joomla</title> | |
| <link href="https://getbootstrap.com/docs/5.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous"> | |
| <link href="https://getbootstrap.com/docs/5.0/examples/sign-in/signin.css" rel="stylesheet"> | |
| </head> | |
| <body class="text-center"> | |
| <main class="form-signin"> | |
| <form action="https://dominio.joomla.com/external-login.html" method="post"> | |
| <img class="mb-4" src="https://cdn.joomla.org/images/Joomla_logo.png" alt="Joomla CMS" width="40" height="40"> | |
| <input type="hidden" id="username" name="username" value="test_login"> | |
| <input type="hidden" id="password" name="password" value="Password#2021"> | |
| <button class="w-100 btn btn-lg btn-primary" type="submit">Log in</button> | |
| </form> | |
| </main> | |
| </body> | |
| </html> |