I have just started learning VueJS. I am using vuejs to call an external api that does CRUD operations for my application. The CRUD operations are made in the admin panel (http://domain.com/admin-dashboard) which requires a username and password. The external api endpoint provides an api/auth
endpoint that accepts a username and a password and if the details are correct provides a JWT token. This token should be used when making the api request for the CRUD operations by passing the token in Authorization header Bearer xxx (where xxx is the token id)
Well everything works fine till here. But the problem is how do I stop someone from accessing the /admin-dashboard
page using vuejs? Earlier the traditional way of doing this in php is something like this:
<?php
session_start();
if(empty($_SESSION['is_logged_in'])){
// Redirect to login page
header('Location login.php');
exit();
}
This way i can be sure that no unauthorized user can access the dashboard. But now since my entire app is based on vuejs, how do I secure the admin-dashboard
page?
Any help will be appreciated.