


The interceptor determines the operation after the token fails and jumps.
This time I will bring you the operation after the interceptor determines the token invalid jump. What are the precautions after the interceptor determines the token invalid jump. The following is a practical case, let's take a look.
Set global token judgment in the interceptor, which means that the token will be verified for every http request, and the token expiration return code agreed with the background can customize the jump path;
var token = window.localStorage.getItem("token"); Vue.http.interceptors.push(function(request, next) { request.headers.set('token', token); //setting request.headers next(function(response){ if(response.body.code===401){ //与后台约定登录失效的返回码 parent.location.href ='/login.html'; } return response }) })
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Detailed explanation of the steps for setting header information in the vue-resource interceptor
js css perfect web page loading User experience at the time
The above is the detailed content of The interceptor determines the operation after the token fails and jumps.. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Solutions to invalid login token include checking whether the Token has expired, checking whether the Token is correct, checking whether the Token has been tampered with, checking whether the Token matches the user, clearing the cache or cookies, checking the network connection and server status, logging in again or requesting a new Token. Contact technical support or developers, etc. Detailed introduction: 1. Check whether the Token has expired. The login Token usually has a validity period set. Once the validity period exceeds, it will be considered invalid, etc.

The problem of invalid login token can be solved by checking the network connection, checking the token validity period, clearing cache and cookies, checking login status, contacting the application developer and strengthening account security. Detailed introduction: 1. Check the network connection, reconnect to the network or change the network environment; 2. Check the token validity period, obtain a new token, or contact the developer of the application; 3. Clear cache and cookies, clear browser cache and Cookie, and then log in to the application again; 4. Check the login status.

Redis stores user tokens. When designing a system similar to e-commerce, a common requirement is that each page needs to carry logged-in user information. There are two common solutions: using cookies to save and using JWT to save. But if Redis cache is used in the system, there is also a third solution - caching the user token in Redis. Generate a token when logging in and store it in Redis //Generate a token object and save it in redis redisTemplate.opsForHash().put("token","user",user)

How to solve the common problem of Laravel login time expiration When using Laravel to develop web applications, login authentication is a very important function. However, sometimes if a user does not operate for a long time after logging in, the page may automatically log out or the authentication may fail. This problem is relatively common. The following will introduce how to solve this problem by setting the session time and provide specific code examples. 1. Set the session expiration time in Laravel, by default sessi

PHP and REDIS: How to implement distributed cache invalidation and update Introduction: In modern distributed systems, cache is a very important component, which can significantly improve the performance and scalability of the system. At the same time, cache invalidation and update is also a very important issue, because if the invalidation and update of cache data cannot be handled correctly, it will lead to system data inconsistency. This article will introduce how to use PHP and REDIS to implement distributed cache invalidation and update, and provide relevant code examples. 1. What is RED

1. Token login authentication jwt: JSONWebToken. It is an authentication protocol that is generally used to verify the requested identity information and identity permissions. Composed of three parts: Header, Hayload, Signatureheader: that is, the header information, which is the basic information describing this token, json format {"alg":"HS256", //indicates the signature algorithm, the default is HMACSHA256 (written as HS256) "type":"JWT"//Indicates the type of Token. JWT tokens are uniformly written as JWT}pa

Token is a kind of virtual currency. It is a digital currency used to represent user permissions, record transaction information, and pay virtual currency. Token can be used to conduct transactions on a specific network, it can be used to buy or sell specific virtual currencies, and it can also be used to pay for specific services.

How to solve C++ syntax error: 'expectedprimary-expressionbefore':'token'? Syntax errors are a common problem in C++ programming. One of the common errors is the "expectedprimary-expressionbefore':'token" error message. This error usually occurs when using conditional expressions and the ternary operator. This article will introduce the cause of this error
