提交 c34ad9a0 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat: ESlint格式化前端代码

上级 0d3e1d09
...@@ -46,6 +46,7 @@ public class F2CRealm extends AuthorizingRealm { ...@@ -46,6 +46,7 @@ public class F2CRealm extends AuthorizingRealm {
} }
//验证登录权限 //验证登录权限
@Override @Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException { protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
String token = (String) auth.getCredentials(); String token = (String) auth.getCredentials();
...@@ -63,7 +64,6 @@ public class F2CRealm extends AuthorizingRealm { ...@@ -63,7 +64,6 @@ public class F2CRealm extends AuthorizingRealm {
} }
String pass = null; String pass = null;
try { try {
/*pass = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, userBean.getPassword());*/
pass = user.getPassword(); pass = user.getPassword();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -6,18 +6,20 @@ import com.auth0.jwt.algorithms.Algorithm; ...@@ -6,18 +6,20 @@ import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException; import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT; import com.auth0.jwt.interfaces.DecodedJWT;
import io.dataease.auth.entity.TokenInfo; import io.dataease.auth.entity.TokenInfo;
import io.dataease.commons.utils.ServletUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.util.Date; import java.util.Date;
public class JWTUtils { public class JWTUtils {
// token过期时间5分钟 (过期会自动刷新续命 目的是避免一直都是同一个token ) // token过期时间5min (过期会自动刷新续命 目的是避免一直都是同一个token )
private static final long EXPIRE_TIME = 1*60*1000; private static final long EXPIRE_TIME = 1*60*1000;
// 登录间隔时间 超过这个时间强制重新登录 // 登录间隔时间10min 超过这个时间强制重新登录
private static final long Login_Interval = 2*60*1000; private static final long Login_Interval = 10*60*1000;
/** /**
...@@ -33,7 +35,17 @@ public class JWTUtils { ...@@ -33,7 +35,17 @@ public class JWTUtils {
.withClaim("username", tokenInfo.getUsername()) .withClaim("username", tokenInfo.getUsername())
.withClaim("userId", tokenInfo.getUserId()) .withClaim("userId", tokenInfo.getUserId())
.build(); .build();
verifier.verify(token); DecodedJWT jwt = verifier.verify(token);
Long lastLoginTime = jwt.getClaim("lastLoginTime").asLong();
long now = System.currentTimeMillis();
if (now - lastLoginTime > Login_Interval){
// 登录超时
HttpServletResponse response = ServletUtils.response();
response.addHeader("Access-Control-Expose-Headers", "authentication-status");
response.setHeader("authentication-status", "login_expire");
// 前端拦截 登录超时状态 直接logout
return false;
}
return true; return true;
} }
......
...@@ -108,4 +108,4 @@ export function post(url, data) { ...@@ -108,4 +108,4 @@ export function post(url, data) {
}) })
} }
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree,defaultTree } export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, defaultTree }
...@@ -683,10 +683,10 @@ export default { ...@@ -683,10 +683,10 @@ export default {
}, },
panel: { panel: {
datalist: '视图列表', datalist: '视图列表',
group:'目录', group: '目录',
panel:'仪表盘', panel: '仪表盘',
groupAdd:'新建目录', groupAdd: '新建目录',
panelAdd:'新建仪表盘', panelAdd: '新建仪表盘',
delete: '删除', delete: '删除',
move_to: '移动到', move_to: '移动到',
rename: '重命名', rename: '重命名',
......
...@@ -52,6 +52,14 @@ const checkAuth = response => { ...@@ -52,6 +52,14 @@ const checkAuth = response => {
}) })
}) })
} }
if (response.headers['authentication-status'] === 'login_expire') {
const message = this.$t('login.expires')
$alert(message, () => {
store.dispatch('user/logout').then(() => {
location.reload()
})
})
}
// token到期后自动续命 刷新token // token到期后自动续命 刷新token
if (response.headers[RefreshTokenKey]) { if (response.headers[RefreshTokenKey]) {
const refreshToken = response.headers[RefreshTokenKey] const refreshToken = response.headers[RefreshTokenKey]
......
...@@ -4,65 +4,65 @@ ...@@ -4,65 +4,65 @@
<ms-aside-container> <ms-aside-container>
<el-tabs v-model="activeName" @tab-click="handleClick"> <el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane name="PanelList"> <el-tab-pane name="PanelList">
<span slot="label"><i class="el-icon-document"></i>列表</span> <span slot="label"><i class="el-icon-document" />列表</span>
<PanelList @switchComponent="switchComponent"/> <PanelList @switchComponent="switchComponent" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="panels_star"> <el-tab-pane name="panels_star">
<span slot="label"><i class="el-icon-star-off"></i>收藏</span> <span slot="label"><i class="el-icon-star-off" />收藏</span>
开发中... 开发中...
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="panels_share"> <el-tab-pane name="panels_share">
<span slot="label"><i class="el-icon-share"></i>分享</span> <span slot="label"><i class="el-icon-share" />分享</span>
开发中... 开发中...
</el-tab-pane> </el-tab-pane>
<!-- <el-tab-pane name="example">--> <!-- <el-tab-pane name="example">-->
<!-- <span slot="label"><i class="el-icon-star-on"></i>示例</span>--> <!-- <span slot="label"><i class="el-icon-star-on"></i>示例</span>-->
<!-- <group @switchComponent="switchComponent"/>--> <!-- <group @switchComponent="switchComponent"/>-->
<!-- </el-tab-pane>--> <!-- </el-tab-pane>-->
</el-tabs> </el-tabs>
</ms-aside-container> </ms-aside-container>
<ms-main-container> <ms-main-container>
<!--<router-view/>--> <!--<router-view/>-->
<component :is="component" :param="param" @switchComponent="switchComponent"/> <component :is="component" :param="param" @switchComponent="switchComponent" />
</ms-main-container> </ms-main-container>
</ms-container> </ms-container>
</template> </template>
<script> <script>
import MsMainContainer from '@/metersphere/common/components/MsMainContainer' import MsMainContainer from '@/metersphere/common/components/MsMainContainer'
import MsContainer from '@/metersphere/common/components/MsContainer' import MsContainer from '@/metersphere/common/components/MsContainer'
import MsAsideContainer from '@/metersphere/common/components/MsAsideContainer' import MsAsideContainer from '@/metersphere/common/components/MsAsideContainer'
// import Group from './group/Group' // import Group from './group/Group'
import PanelList from './list/PanelList' import PanelList from './list/PanelList'
import PanelView from './list/PanelView' import PanelView from './list/PanelView'
export default { export default {
name: 'Panel', name: 'Panel',
components: {MsMainContainer, MsContainer, MsAsideContainer, PanelList,PanelView}, components: { MsMainContainer, MsContainer, MsAsideContainer, PanelList, PanelView },
data() { data() {
return { return {
component: PanelView, component: PanelView,
param: {}, param: {},
activeName: 'PanelList' activeName: 'PanelList'
} }
},
methods: {
handleClick(tab, event) {
console.log(tab, event)
}, },
methods: { switchComponent(c) {
handleClick(tab, event) { console.log(c)
console.log(tab, event) this.param = c.param
}, switch (c.name) {
switchComponent(c) { case 'PanelView':
console.log(c) this.component = PanelView
this.param = c.param break
switch (c.name) {
case 'PanelView':
this.component = PanelView
break
}
} }
} }
} }
}
</script> </script>
<style scoped> <style scoped>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论