parent
9fb5e620b6
commit
82fd60a4d7
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"java.compile.nullAnalysis.mode": "automatic"
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.luojia_channel.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MybatisConfig {
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.luojia_channel.common.config;
|
||||
|
||||
import com.luojia_channel.common.interceptor.AuthInterceptor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
private final AuthInterceptor authInterceptor;
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 登录拦截器
|
||||
registry.addInterceptor(authInterceptor)
|
||||
.excludePathPatterns("/user/login",
|
||||
"/user/register"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.luojia_channel.common.constants;
|
||||
|
||||
public class RedisConstant {
|
||||
// redis存储的refreshToken前缀
|
||||
public static final String REFRESH_TOKEN_PREFIX = "refresh_token:";
|
||||
// redis存储的黑名单前缀
|
||||
public static final String BLACKLIST_PREFIX = "blacklist:";
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.luojia_channel.common.interceptor;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.luojia_channel.common.domain.Result;
|
||||
import com.luojia_channel.common.domain.UserDTO;
|
||||
import com.luojia_channel.common.exception.UserException;
|
||||
import com.luojia_channel.common.utils.JWTUtil;
|
||||
import com.luojia_channel.common.utils.UserContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AuthInterceptor implements HandlerInterceptor {
|
||||
|
||||
private final JWTUtil jwtUtil;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
Object handler) throws Exception {
|
||||
// 获取请求中的双Token
|
||||
String accessToken = request.getHeader("Authorization");
|
||||
String refreshToken = request.getHeader("X-Refresh-Token");
|
||||
try {
|
||||
// 验证Token并处理自动刷新
|
||||
UserDTO user = jwtUtil.checkLogin(accessToken, refreshToken);
|
||||
// 将新Token写入响应头
|
||||
if (user.getAccessToken() != null) {
|
||||
response.setHeader("New-Access-Token", JWTUtil.TOKEN_PREFIX + user.getAccessToken());
|
||||
response.setHeader("New-Refresh-Token", user.getRefreshToken());
|
||||
}
|
||||
// 将用户信息存入请求上下文
|
||||
UserContext.setUser(user);
|
||||
return true;
|
||||
} catch (UserException ex) {
|
||||
// Token验证失败处理
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||
response.getWriter().write(
|
||||
JSON.toJSONString(Result.fail(ex.getMessage()))
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,11 @@
|
||||
package com.luojia_channel.modules.user.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user/info")
|
||||
@RequiredArgsConstructor
|
||||
public class UserInfoController {
|
||||
}
|
||||
|
@ -1,29 +1,28 @@
|
||||
# 本地开发环境
|
||||
lj:
|
||||
db:
|
||||
host: 192.168.59.129
|
||||
password: Forely123!
|
||||
redis:
|
||||
host: 192.168.59.129
|
||||
port: 6379
|
||||
password: Forely123!
|
||||
rabbitmq:
|
||||
host: 192.168.59.129
|
||||
port: 5672
|
||||
username: admin
|
||||
password: Forely123!
|
||||
|
||||
# 本地开发环境,cf的配置
|
||||
#lj:
|
||||
# db:
|
||||
# host: localhost
|
||||
# password: 123456
|
||||
# host: 192.168.59.129
|
||||
# password: Forely123!
|
||||
# redis:
|
||||
# host: localhost
|
||||
# host: 192.168.59.129
|
||||
# port: 6379
|
||||
# password: 123456
|
||||
# password: Forely123!
|
||||
# rabbitmq:
|
||||
# host: localhost
|
||||
# port: 15672
|
||||
# username: root
|
||||
# password: 123456
|
||||
# host: 192.168.59.129
|
||||
# port: 5672
|
||||
# username: admin
|
||||
# password: Forely123!
|
||||
|
||||
lj:
|
||||
db:
|
||||
host: localhost
|
||||
passwprd: 123456
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
password: 123456
|
||||
rabbitmq:
|
||||
host: localhost
|
||||
port: 15672
|
||||
username: root
|
||||
password: 123456
|
@ -1,29 +1,28 @@
|
||||
# 本地开发环境
|
||||
lj:
|
||||
db:
|
||||
host: 192.168.59.129
|
||||
password: Forely123!
|
||||
redis:
|
||||
host: 192.168.59.129
|
||||
port: 6379
|
||||
password: Forely123!
|
||||
rabbitmq:
|
||||
host: 192.168.59.129
|
||||
port: 5672
|
||||
username: admin
|
||||
password: Forely123!
|
||||
|
||||
# 本地开发环境,cf的配置
|
||||
#lj:
|
||||
# db:
|
||||
# host: localhost
|
||||
# password: 123456
|
||||
# host: 192.168.59.129
|
||||
# password: Forely123!
|
||||
# redis:
|
||||
# host: localhost
|
||||
# host: 192.168.59.129
|
||||
# port: 6379
|
||||
# password: 123456
|
||||
# password: Forely123!
|
||||
# rabbitmq:
|
||||
# host: localhost
|
||||
# port: 15672
|
||||
# username: root
|
||||
# password: 123456
|
||||
# host: 192.168.59.129
|
||||
# port: 5672
|
||||
# username: admin
|
||||
# password: Forely123!
|
||||
|
||||
lj:
|
||||
db:
|
||||
host: localhost
|
||||
passwprd: 123456
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
password: 123456
|
||||
rabbitmq:
|
||||
host: localhost
|
||||
port: 15672
|
||||
username: root
|
||||
password: 123456
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,23 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
@ -0,0 +1,24 @@
|
||||
# vue-frontend
|
||||
|
||||
## Project setup
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
```
|
||||
npm run serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
npm run lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "esnext",
|
||||
"baseUrl": "./",
|
||||
"moduleResolution": "node",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
},
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"scripthost"
|
||||
]
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "vue-frontend",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.8.4",
|
||||
"core-js": "^3.8.3",
|
||||
"vue": "^3.2.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.16",
|
||||
"@babel/eslint-parser": "^7.12.16",
|
||||
"@vue/cli-plugin-babel": "~5.0.0",
|
||||
"@vue/cli-plugin-eslint": "~5.0.0",
|
||||
"@vue/cli-service": "~5.0.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-vue": "^8.0.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:vue/vue3-essential",
|
||||
"eslint:recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"parser": "@babel/eslint-parser"
|
||||
},
|
||||
"rules": {}
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not dead",
|
||||
"not ie 11"
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 4.2 KiB |
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title>Responsive Login And Registration</title>
|
||||
<link href='<%= BASE_URL %>css/boxicons.min.css' rel='stylesheet'>
|
||||
<link rel="stylesheet" href="<%= BASE_URL %>css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="<%= BASE_URL %>js/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
After Width: | Height: | Size: 6.7 KiB |
@ -0,0 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
|
||||
createApp(App).mount('#app')
|
@ -0,0 +1,29 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import Home from '../views/Home.vue';
|
||||
import Login from '../components/Login.vue';
|
||||
import Register from '../components/Register.vue';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: Home
|
||||
},
|
||||
{
|
||||
path: '/user/login',
|
||||
name: 'Login',
|
||||
component: Login
|
||||
},
|
||||
{
|
||||
path: '/user/register',
|
||||
name: 'Register',
|
||||
component: Register
|
||||
}
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
routes
|
||||
});
|
||||
|
||||
export default router;
|
@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>欢迎来到珞珈岛</h1>
|
||||
</div>
|
||||
</template>
|
@ -0,0 +1,4 @@
|
||||
const { defineConfig } = require('@vue/cli-service')
|
||||
module.exports = defineConfig({
|
||||
transpileDependencies: true
|
||||
})
|
Loading…
Reference in new issue