Webapp single page token question?

I said two pages, not one page, two. Say important things three times. I said that when I enter the administration page, I will verify it. I am talking about from the login page to the administration page. (note that the login page is a separate page, which is not the same page as the administration page, which is completely separate.)

We all know that the scenario of using jsonWebToken is to manually send a request to add Authorization to the header to judge. What I want to ask is,

for example, the background management page is an entire page, and the background login page is an entire page. If it is token verification, for example, if I visit content (management page: without login) how to identify, we all know that if session, when visiting this url, For example, the address of the management page is http://localhost:3000/admin/content, on the server, you can know whether you are logged in, jump directly without login, or change the static page of the url output login page

.
var Koa = require("koa");
var static = require("koa-static");//
app.use(static(
  path.join( __dirname,  "./static")
))

if it is token, we all know that static files are handled at the back end of the server, and static files are output directly. Even if I put a middleware at the front, I cannot get the locally stored token, because the user accesses the static file directly, not the authentication after logging in.

The problem with

ps: is that from the login page to the management page, when the login is successful, a token is added to the information returned by the backend to store it locally, and then jump to the management page. This is OK, but what about the user directly skipping the login page to access the management page? The server has no way to know whether he is logged in or not when he visits the static page.

what should I do? Seek ideas

Mar.21,2021

has also been using node and frontend recently, so let's say two sentences. On my side, react and node,node only do API processing, and token is handled in the same way as you. But if token expires, go directly to other pages and skip the landing page. If any interface is requested on that page, I will return the token expiration to the frontend. Based on this information, the frontend returns directly to the landing page, hoping to help you. This is a project address that I recently played with node-koa


, if you use express framework, I can tell you to use express-session middleware, of course, koa should also have corresponding middleware, you can look for it. Is to store the user information in the background, and you can take it directly if you use it. Hope to help you


for example, vue can use the hook function router.beforeEnter () to determine whether there is a local token before entering the route (this token is saved locally only after logging in successfully). If it exists, directly next () enters the content page. If it does not exist, next ('/ login') jumps to the login page, and will not first enter the bad process of logging in content without requesting a token.


1.token can be checked on the client side. When entering each page, determine whether there is a token,. If so, enter the page
2. After entering the page, api is usually called or a request is made to the backend. When the backend accepts the request, the backend makes permission judgment


token verification means that you directly modify the browser address. At this time, you need to determine whether there is a local token, or not and jump to the login page directly. If the token expires, the backend will certainly return a token expired status code. Whether you need to log in again or return a new token needs to be dealt with according to your business needs.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31823-2b2e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31823-2b2e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?