[Sory for my bad English]
Hi!
I'm angular developer, has no knowledge in WordPress.
I developed a small app, and was asked by the customer to upload it to his website.
His site is a WordPress site, hosted on Bluehost. Because angular application is a client code, I copied (with cPanel file manager) the files to a subfolder within the site folder, and i can serve them successfully.
But now, I have to protect my app. That is: while the entire site is open to the world, my app, which is stored in a subfolder, should be for internal use by the organization, and open only to registered users.
Ther is any way to do it with WordPress/Bluehost infrastructure, without write new user management applicatoin?
Thanks for any help.
You could auth user using WordPress's accounts system, it's the easiest way. Just rename your index.html
to index.php
and preappend the code blew to the header of index.php
<?php
require_once __DIR__ . '/../wp-load.php';
// check if a wordpress user has logged in
if (!is_user_logged_in()) {
$app_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
// redirect to wordpress login page
wp_redirect(wp_login_url($app_url), 302);
exit;
}
?>
<!-- your code begin -->
<html>
my app content
</html>