Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
0c7ba5cb
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 大约 3 年
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0c7ba5cb
编写于
11月 30, 2020
作者:
C
chenjianxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 认证相关请求返回4xx响应码
上级
0a86e8a8
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
16 addition
and
16 deletion
+16
-16
backend/src/main/java/io/metersphere/service/UserService.java
...end/src/main/java/io/metersphere/service/UserService.java
+6
-10
frontend/src/common/js/ajax.js
frontend/src/common/js/ajax.js
+10
-6
未找到文件。
backend/src/main/java/io/metersphere/service/UserService.java
浏览文件 @
0c7ba5cb
...
...
@@ -552,7 +552,6 @@ public class UserService {
public
ResultHolder
login
(
LoginRequest
request
)
{
String
login
=
(
String
)
SecurityUtils
.
getSubject
().
getSession
().
getAttribute
(
"authenticate"
);
String
msg
;
String
username
=
StringUtils
.
trim
(
request
.
getUsername
());
String
password
=
""
;
if
(!
StringUtils
.
equals
(
login
,
UserSource
.
LDAP
.
name
()))
{
...
...
@@ -564,7 +563,6 @@ public class UserService {
UsernamePasswordToken
token
=
new
UsernamePasswordToken
(
username
,
password
);
Subject
subject
=
SecurityUtils
.
getSubject
();
try
{
subject
.
login
(
token
);
if
(
subject
.
isAuthenticated
())
{
...
...
@@ -588,20 +586,18 @@ public class UserService {
return
ResultHolder
.
error
(
Translator
.
get
(
"login_fail"
));
}
}
catch
(
ExcessiveAttemptsException
e
)
{
msg
=
Translator
.
get
(
"excessive_attempts"
);
throw
new
ExcessiveAttemptsException
(
Translator
.
get
(
"excessive_attempts"
)
);
}
catch
(
LockedAccountException
e
)
{
msg
=
Translator
.
get
(
"user_locked"
);
throw
new
LockedAccountException
(
Translator
.
get
(
"user_locked"
)
);
}
catch
(
DisabledAccountException
e
)
{
msg
=
Translator
.
get
(
"user_has_been_disabled"
);
throw
new
DisabledAccountException
(
Translator
.
get
(
"user_has_been_disabled"
)
);
}
catch
(
ExpiredCredentialsException
e
)
{
msg
=
Translator
.
get
(
"user_expires"
);
throw
new
ExpiredCredentialsException
(
Translator
.
get
(
"user_expires"
)
);
}
catch
(
AuthenticationException
e
)
{
msg
=
e
.
getMessage
(
);
throw
new
AuthenticationException
(
e
.
getMessage
()
);
}
catch
(
UnauthorizedException
e
)
{
msg
=
Translator
.
get
(
"not_authorized"
)
+
e
.
getMessage
(
);
throw
new
UnauthorizedException
(
Translator
.
get
(
"not_authorized"
)
+
e
.
getMessage
()
);
}
MSException
.
throwException
(
msg
);
return
null
;
}
public
List
<
User
>
searchUser
(
String
condition
)
{
...
...
frontend/src/common/js/ajax.js
浏览文件 @
0c7ba5cb
...
...
@@ -5,6 +5,10 @@ import i18n from '../../i18n/i18n'
export
default
{
install
(
Vue
)
{
// 登入请求不重定向
let
unRedirectUrls
=
new
Set
([
'
signin
'
]);
if
(
!
axios
)
{
window
.
console
.
error
(
'
You have to install axios
'
);
return
...
...
@@ -50,12 +54,12 @@ export default {
result
.
loading
=
false
;
}
function
exception
(
error
,
result
)
{
if
(
error
.
response
&&
error
.
response
.
status
===
401
)
{
function
exception
(
error
,
result
,
url
)
{
if
(
error
.
response
&&
error
.
response
.
status
===
401
&&
!
unRedirectUrls
.
has
(
url
)
)
{
login
();
return
;
}
if
(
error
.
response
&&
error
.
response
.
status
===
403
)
{
if
(
error
.
response
&&
error
.
response
.
status
===
403
&&
!
unRedirectUrls
.
has
(
url
)
)
{
window
.
location
.
href
=
"
/
"
;
return
;
}
...
...
@@ -78,7 +82,7 @@ export default {
axios
.
get
(
url
,
{
params
:
data
}).
then
(
response
=>
{
then
(
success
,
response
,
result
);
}).
catch
(
error
=>
{
exception
(
error
,
result
);
exception
(
error
,
result
,
url
);
});
return
result
;
}
...
...
@@ -92,7 +96,7 @@ export default {
axios
.
get
(
url
).
then
(
response
=>
{
then
(
success
,
response
,
result
);
}).
catch
(
error
=>
{
exception
(
error
,
result
);
exception
(
error
,
result
,
url
);
});
return
result
;
}
...
...
@@ -106,7 +110,7 @@ export default {
axios
.
post
(
url
,
data
).
then
(
response
=>
{
then
(
success
,
response
,
result
);
}).
catch
(
error
=>
{
exception
(
error
,
result
);
exception
(
error
,
result
,
url
);
if
(
failure
)
{
then
(
failure
,
error
,
result
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录