Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
app-manage-console
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
ReactNative
app-manage-console
Commits
56540934
提交
56540934
authored
12月 18, 2017
作者:
vipcxj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修正关于uca登录的bug
上级
aa0a8707
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
35 行增加
和
21 行删除
+35
-21
index.js
src/components/uca/index.js
+18
-12
login.js
src/models/login.js
+4
-4
uca.js
src/services/uca.js
+1
-1
error.js
src/utils/error.js
+2
-2
uca.js
src/utils/uca.js
+10
-2
没有找到文件。
src/components/uca/index.js
浏览文件 @
56540934
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
PropTypes
from
'prop-types'
;
import
PropTypes
from
'prop-types'
;
import
{
Input
,
Spin
}
from
'antd'
;
import
{
Input
,
Spin
}
from
'antd'
;
import
{
debounce
}
from
'lodash'
;
import
{
getCert
,
init
,
sign
}
from
'../../utils/uca'
;
import
{
getCert
,
init
,
sign
}
from
'../../utils/uca'
;
class
UCA
extends
Component
{
class
UCA
extends
Component
{
...
@@ -34,23 +33,30 @@ class UCA extends Component {
...
@@ -34,23 +33,30 @@ class UCA extends Component {
onChange
=
(
value
)
=>
{
onChange
=
(
value
)
=>
{
if
(
this
.
state
.
ready
&&
this
.
props
.
onChange
)
{
if
(
this
.
state
.
ready
&&
this
.
props
.
onChange
)
{
if
(
value
)
{
this
.
props
.
onChange
(
this
.
valueToObj
(
value
));
if
(
this
.
props
.
data
)
{
}
this
.
props
.
onChange
(
sign
(
value
,
this
.
props
.
data
));
};
}
else
{
objToValue
=
(
obj
)
=>
{
this
.
props
.
onChange
(
getCert
(
value
));
return
obj
?
obj
.
input
:
''
;
}
};
}
valueToObj
=
(
value
)
=>
{
if
(
!
value
)
{
return
value
;
}
if
(
this
.
props
.
data
)
{
return
sign
(
value
,
this
.
props
.
data
);
}
else
{
return
getCert
(
value
);
}
}
};
};
render
()
{
render
()
{
const
onChange
=
(
e
)
=>
{
const
onChange
=
(
e
)
=>
{
return
debounce
(
this
.
onChange
,
300
)
(
e
.
target
.
value
);
return
this
.
onChange
(
e
.
target
.
value
);
};
};
const
{
loading
,
...
rest
}
=
this
.
props
;
const
{
loading
,
value
,
...
rest
}
=
this
.
props
;
return
(
return
(
<
Spin
spinning
=
{
!
this
.
state
.
ready
&&
loading
}
size
=
"small"
>
<
Spin
spinning
=
{
!
this
.
state
.
ready
||
loading
}
size
=
"small"
>
<
Input
{...
rest
}
onChange
=
{
onChange
}
type
=
"password"
/>
<
Input
{...
rest
}
disabled
=
{
!
this
.
state
.
ready
||
loading
}
value
=
{
this
.
objToValue
(
value
)}
onChange
=
{
onChange
}
/
>
<
/Spin
>
<
/Spin
>
);
);
}
}
...
...
src/models/login.js
浏览文件 @
56540934
...
@@ -111,8 +111,8 @@ export default {
...
@@ -111,8 +111,8 @@ export default {
yield
put
({
type
:
'setStatus'
,
payload
:
'auth'
});
yield
put
({
type
:
'setStatus'
,
payload
:
'auth'
});
},
},
*
requestUCACode
(
ignored
,
{
call
,
put
})
{
*
requestUCACode
(
ignored
,
{
call
,
put
})
{
const
code
=
yield
call
(
authorize
,
yield
call
(
requestCode
,
encrypt
(
tkId
)));
const
{
data
}
=
yield
call
(
authorize
,
yield
call
(
requestCode
,
encrypt
(
tkId
)));
yield
put
({
type
:
'setUCACode'
,
payload
:
code
});
yield
put
({
type
:
'setUCACode'
,
payload
:
data
});
},
},
*
auth
({
payload
:
{
password
,
uca
}
},
{
call
})
{
*
auth
({
payload
:
{
password
,
uca
}
},
{
call
})
{
let
response
;
let
response
;
...
@@ -122,9 +122,9 @@ export default {
...
@@ -122,9 +122,9 @@ export default {
response
=
yield
call
(
authorize
,
yield
call
(
ucaValidate
,
uca
,
encrypt
(
tkId
)));
response
=
yield
call
(
authorize
,
yield
call
(
ucaValidate
,
uca
,
encrypt
(
tkId
)));
}
}
if
(
response
)
{
if
(
response
)
{
const
{
status
,
remainedAuthRequirements
}
=
response
;
const
{
status
,
remainedAuthRequirements
,
data
}
=
response
;
if
(
status
!==
'authed'
&&
status
!==
'skipped'
)
{
if
(
status
!==
'authed'
&&
status
!==
'skipped'
)
{
throw
errors
.
authFailed
();
throw
errors
.
authFailed
(
data
);
}
}
if
(
remainedAuthRequirements
.
requirements
.
length
===
0
)
{
if
(
remainedAuthRequirements
.
requirements
.
length
===
0
)
{
yield
call
(
successAuthed
,
tkId
);
yield
call
(
successAuthed
,
tkId
);
...
...
src/services/uca.js
浏览文件 @
56540934
...
@@ -2,5 +2,5 @@ import post from '../utils/post';
...
@@ -2,5 +2,5 @@ import post from '../utils/post';
import
config
from
'../utils/config'
;
import
config
from
'../utils/config'
;
export
const
bindCert
=
async
(
uid
,
cert
)
=>
{
export
const
bindCert
=
async
(
uid
,
cert
)
=>
{
return
post
(
`
${
config
.
apiContextPath
}
/api/uca/admin/cert`
,
{
uid
,
cert
:
encodeURIComponent
(
cert
)
});
return
post
(
`
${
config
.
apiContextPath
}
/api/uca/admin/cert`
,
{
uid
,
cert
});
};
};
src/utils/error.js
浏览文件 @
56540934
...
@@ -84,9 +84,9 @@ export const errors = {
...
@@ -84,9 +84,9 @@ export const errors = {
code
:
errorCodes
.
wrong_password
,
code
:
errorCodes
.
wrong_password
,
msg
:
'密码错误!'
,
msg
:
'密码错误!'
,
}),
}),
authFailed
:
()
=>
createError
({
authFailed
:
msg
=>
createError
({
code
:
errorCodes
.
auth_failed
,
code
:
errorCodes
.
auth_failed
,
msg
:
'登录验证失败!'
,
msg
:
`登录验证失败!
${
msg
}
`
,
}),
}),
unsupportedAuthType
:
(...
types
)
=>
createError
({
unsupportedAuthType
:
(...
types
)
=>
createError
({
code
:
errorCodes
.
unsupported_auth_type
,
code
:
errorCodes
.
unsupported_auth_type
,
...
...
src/utils/uca.js
浏览文件 @
56540934
...
@@ -37,6 +37,7 @@ export const getCert = (password) => {
...
@@ -37,6 +37,7 @@ export const getCert = (password) => {
if
(
!
safeEngine
)
{
if
(
!
safeEngine
)
{
return
{
return
{
status
:
1
,
status
:
1
,
input
:
password
,
error
:
'未安装USB证书控件。'
,
error
:
'未安装USB证书控件。'
,
};
};
}
}
...
@@ -44,6 +45,7 @@ export const getCert = (password) => {
...
@@ -44,6 +45,7 @@ export const getCert = (password) => {
if
(
safeEngine
.
ErrorCode
!==
0
)
{
if
(
safeEngine
.
ErrorCode
!==
0
)
{
return
{
return
{
status
:
safeEngine
.
ErrorCode
,
status
:
safeEngine
.
ErrorCode
,
input
:
password
,
error
:
'USB-KEY初始化失败,请确认USB-KEY是否插入或密码是否正确。'
,
error
:
'USB-KEY初始化失败,请确认USB-KEY是否插入或密码是否正确。'
,
};
};
}
}
...
@@ -52,12 +54,14 @@ export const getCert = (password) => {
...
@@ -52,12 +54,14 @@ export const getCert = (password) => {
if
(
safeEngine
.
ErrorCode
!==
0
)
{
if
(
safeEngine
.
ErrorCode
!==
0
)
{
return
{
return
{
status
:
safeEngine
.
ErrorCode
,
status
:
safeEngine
.
ErrorCode
,
input
:
password
,
error
:
`获取个人证书错误,错误代码为:
${
safeEngine
.
ErrorCode
}
。`
,
error
:
`获取个人证书错误,错误代码为:
${
safeEngine
.
ErrorCode
}
。`
,
};
};
}
}
const
res
=
{
const
res
=
{
status
:
0
,
status
:
0
,
cert
,
cert
,
input
:
password
,
};
};
const
deadTime
=
safeEngine
.
SEH_GetCertValidDate
(
cert
);
const
deadTime
=
safeEngine
.
SEH_GetCertValidDate
(
cert
);
res
.
deadTime
=
parseInt
(
deadTime
,
10
);
res
.
deadTime
=
parseInt
(
deadTime
,
10
);
...
@@ -77,7 +81,7 @@ export const getCert = (password) => {
...
@@ -77,7 +81,7 @@ export const getCert = (password) => {
* 签名
* 签名
* @param password usb-key的密钥
* @param password usb-key的密钥
* @param data 需要签名的数据,从服务端获取
* @param data 需要签名的数据,从服务端获取
* @return {{[cert]: string, [deadTime]: number, [signed]: string, status: number, [error]: string}}
* @return {{
input: string,
[cert]: string, [deadTime]: number, [signed]: string, status: number, [error]: string}}
*/
*/
export
const
sign
=
(
password
,
data
)
=>
{
export
const
sign
=
(
password
,
data
)
=>
{
if
(
bowser
.
msie
||
bowser
.
msedge
)
{
if
(
bowser
.
msie
||
bowser
.
msedge
)
{
...
@@ -85,6 +89,7 @@ export const sign = (password, data) => {
...
@@ -85,6 +89,7 @@ export const sign = (password, data) => {
if
(
!
safeEngine
)
{
if
(
!
safeEngine
)
{
return
{
return
{
status
:
1
,
status
:
1
,
input
:
password
,
error
:
'未安装USB证书控件。'
,
error
:
'未安装USB证书控件。'
,
};
};
}
}
...
@@ -92,6 +97,7 @@ export const sign = (password, data) => {
...
@@ -92,6 +97,7 @@ export const sign = (password, data) => {
if
(
safeEngine
.
ErrorCode
!==
0
)
{
if
(
safeEngine
.
ErrorCode
!==
0
)
{
return
{
return
{
status
:
safeEngine
.
ErrorCode
,
status
:
safeEngine
.
ErrorCode
,
input
:
password
,
error
:
'USB-KEY初始化失败,请确认USB-KEY是否插入或密码是否正确。'
,
error
:
'USB-KEY初始化失败,请确认USB-KEY是否插入或密码是否正确。'
,
};
};
}
}
...
@@ -100,16 +106,18 @@ export const sign = (password, data) => {
...
@@ -100,16 +106,18 @@ export const sign = (password, data) => {
if
(
safeEngine
.
ErrorCode
!==
0
)
{
if
(
safeEngine
.
ErrorCode
!==
0
)
{
return
{
return
{
status
:
safeEngine
.
ErrorCode
,
status
:
safeEngine
.
ErrorCode
,
input
:
password
,
error
:
`获取个人证书错误,错误代码为:
${
safeEngine
.
ErrorCode
}
。`
,
error
:
`获取个人证书错误,错误代码为:
${
safeEngine
.
ErrorCode
}
。`
,
};
};
}
}
const
res
=
{
cert
,
status
:
0
};
const
res
=
{
cert
,
status
:
0
,
input
:
password
};
const
deadTime
=
safeEngine
.
SEH_GetCertValidDate
(
cert
);
const
deadTime
=
safeEngine
.
SEH_GetCertValidDate
(
cert
);
res
.
deadTime
=
parseInt
(
deadTime
,
10
);
res
.
deadTime
=
parseInt
(
deadTime
,
10
);
const
signed
=
safeEngine
.
SEH_SignData
(
data
,
3
);
const
signed
=
safeEngine
.
SEH_SignData
(
data
,
3
);
if
(
safeEngine
.
ErrorCode
!==
0
)
{
if
(
safeEngine
.
ErrorCode
!==
0
)
{
return
{
return
{
status
:
safeEngine
.
ErrorCode
,
status
:
safeEngine
.
ErrorCode
,
input
:
password
,
error
:
`数字签名失败,错误代码为:
${
safeEngine
.
ErrorCode
}
。`
,
error
:
`数字签名失败,错误代码为:
${
safeEngine
.
ErrorCode
}
。`
,
};
};
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论