Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
app-manage-console
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
ReactNative
app-manage-console
Commits
c678dd1e
提交
c678dd1e
authored
12月 19, 2017
作者:
vipcxj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.修复可选多种验证方式的输入控件各种错误
2.实现记住用户名功能
上级
368b5931
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
33 行增加
和
62 行删除
+33
-62
login.js
src/models/login.js
+7
-42
authInput.js
src/routes/login/authInput.js
+1
-3
index.js
src/routes/login/index.js
+13
-10
auth.js
src/utils/auth.js
+12
-7
没有找到文件。
src/models/login.js
浏览文件 @
c678dd1e
...
@@ -9,7 +9,8 @@ import { errors } from '../utils/error';
...
@@ -9,7 +9,8 @@ import { errors } from '../utils/error';
import
config
from
'../utils/config'
;
import
config
from
'../utils/config'
;
import
{
getStore
}
from
'../index'
;
import
{
getStore
}
from
'../index'
;
const
successAuthed
=
async
(
tokenId
)
=>
{
const
successAuthed
=
async
(
tokenId
,
userName
,
remember
)
=>
{
await
histories
.
pushHistory
(
'userName'
,
remember
?
userName
:
''
);
await
setToken
(
tokenId
);
await
setToken
(
tokenId
);
const
uInfo
=
await
userInfo
();
const
uInfo
=
await
userInfo
();
await
setUser
(
uInfo
.
id
,
uInfo
.
name
);
await
setUser
(
uInfo
.
id
,
uInfo
.
name
);
...
@@ -86,13 +87,14 @@ export default {
...
@@ -86,13 +87,14 @@ export default {
},
},
},
},
effects
:
{
effects
:
{
*
init
(
ignored
,
{
put
})
{
*
init
(
ignored
,
{
put
,
call
})
{
yield
put
({
type
:
'setStatus'
,
payload
:
'login'
});
yield
put
({
type
:
'setStatus'
,
payload
:
'login'
});
yield
put
({
type
:
'setUCACode'
,
payload
:
''
});
yield
put
({
type
:
'setUCACode'
,
payload
:
''
});
yield
put
({
type
:
'setAuthRequires'
,
payload
:
[]
});
yield
put
({
type
:
'setAuthRequires'
,
payload
:
[]
});
const
userName
=
yield
call
(
histories
.
getLatest
,
'userName'
);
yield
put
({
type
:
'setUserName'
,
payload
:
userName
||
''
});
},
},
*
login
({
payload
:
userName
},
{
call
,
put
})
{
*
login
({
payload
:
userName
},
{
call
,
put
})
{
yield
put
({
type
:
'setUserName'
,
userName
});
const
{
tokenId
,
remainedAuthRequirements
}
=
yield
call
(
login
,
{
const
{
tokenId
,
remainedAuthRequirements
}
=
yield
call
(
login
,
{
type
:
'userName'
,
type
:
'userName'
,
data
:
userName
,
data
:
userName
,
...
@@ -114,7 +116,7 @@ export default {
...
@@ -114,7 +116,7 @@ export default {
const
{
data
}
=
yield
call
(
authorize
,
yield
call
(
requestCode
,
encrypt
(
tkId
)));
const
{
data
}
=
yield
call
(
authorize
,
yield
call
(
requestCode
,
encrypt
(
tkId
)));
yield
put
({
type
:
'setUCACode'
,
payload
:
data
});
yield
put
({
type
:
'setUCACode'
,
payload
:
data
});
},
},
*
auth
({
payload
:
{
password
,
uca
}
},
{
call
})
{
*
auth
({
payload
:
{
userName
,
password
,
uca
,
remember
}
},
{
call
})
{
let
response
;
let
response
;
if
(
password
)
{
if
(
password
)
{
response
=
yield
call
(
authorize
,
yield
call
(
passValidate
,
password
,
encrypt
(
tkId
)));
response
=
yield
call
(
authorize
,
yield
call
(
passValidate
,
password
,
encrypt
(
tkId
)));
...
@@ -140,47 +142,10 @@ export default {
...
@@ -140,47 +142,10 @@ export default {
throw
errors
.
authFailed
(
data
);
throw
errors
.
authFailed
(
data
);
}
}
if
(
remainedAuthRequirements
.
requirements
.
length
===
0
)
{
if
(
remainedAuthRequirements
.
requirements
.
length
===
0
)
{
yield
call
(
successAuthed
,
tkId
);
yield
call
(
successAuthed
,
tkId
,
userName
,
remember
);
}
}
}
}
},
},
/* *login({ payload }, { call, put }) {
const loginRequest = {
type: 'userName',
data: payload.userName,
authRequest: yield call(validate, payload.password),
};
const result = yield call(login, loginRequest);
const { tokenId, authResponse, remainedAuthRequirements } = result;
if (authResponse.status !== 'authed' && authResponse.status !== 'skipped') {
throw errors.wrongPassword();
}
const { requirements } = remainedAuthRequirements;
if (requirements.length > 0) {
throw errors.unsupportedAuthType(requirements);
}
yield call(setToken, tokenId);
const uInfo = yield call(userInfo);
yield call(setUser, uInfo.id, uInfo.name);
const path = yield call(histories.getLatest, 'domain');
if (!path) {
yield put(routerRedux.push(fullPath('/domain')));
} else {
yield call(switchDomain, path);
const domain = yield call(currentDomain);
if (domain) {
yield call(setDomain, domain.name, path);
const latest = yield call(histories.getLatest, 'module');
if (latest && config.fastNavigationPage) {
yield put(routerRedux.push(fullPath('/fastNav')));
} else {
yield put(routerRedux.push(fullPath('/main')));
}
} else {
yield put(routerRedux.push(fullPath('/domain')));
}
}
},*/
},
},
subscriptions
:
{},
subscriptions
:
{},
};
};
src/routes/login/authInput.js
浏览文件 @
c678dd1e
...
@@ -26,10 +26,8 @@ class AuthInputs extends React.Component {
...
@@ -26,10 +26,8 @@ class AuthInputs extends React.Component {
}
}
<
/Select
>
<
/Select
>
{
{
React
.
cloneElement
(
data
[
this
.
state
.
index
>=
0
?
this
.
state
.
index
:
0
].
node
,
React
.
cloneElement
(
data
[
this
.
state
.
index
>=
0
?
this
.
state
.
index
:
0
].
node
()
,
{
{
value
:
this
.
props
.
value
,
onChange
:
this
.
props
.
onChange
,
style
:
{
width
:
'70%'
},
style
:
{
width
:
'70%'
},
})
})
}
}
...
...
src/routes/login/index.js
浏览文件 @
c678dd1e
...
@@ -83,12 +83,12 @@ class LoginForm extends React.Component {
...
@@ -83,12 +83,12 @@ class LoginForm extends React.Component {
{
{
key
:
'password'
,
key
:
'password'
,
label
:
'密码'
,
label
:
'密码'
,
node
:
this
.
createPassword
(
focus
),
node
:
()
=>
this
.
createPassword
(
focus
),
},
},
{
{
key
:
'uca'
,
key
:
'uca'
,
label
:
'证书'
,
label
:
'证书'
,
node
:
this
.
createUCA
(
focus
),
node
:
()
=>
this
.
createUCA
(
focus
),
},
},
]}
]}
/
>
/
>
...
@@ -127,12 +127,21 @@ class LoginForm extends React.Component {
...
@@ -127,12 +127,21 @@ class LoginForm extends React.Component {
<
Form
.
Item
>
<
Form
.
Item
>
{
{
getFieldDecorator
(
'userName'
,
{
getFieldDecorator
(
'userName'
,
{
initialValue
:
this
.
props
.
login
.
userName
,
rules
:
[{
rules
:
[{
required
:
true
,
required
:
true
,
message
:
'请输入用户名。'
,
message
:
'请输入用户名。'
,
}],
}],
})(
})(
<
Input
autoFocus
=
{
!
this
.
authFocus
}
onBlur
=
{
this
.
onUserBlur
}
prefix
=
{
<
Icon
type
=
"user"
/>
}
placeholder
=
"用户名"
/>
,
<
Input
autoFocus
=
{
!
this
.
authFocus
}
onBlur
=
{
this
.
onUserBlur
}
prefix
=
{
<
Icon
type
=
"user"
/>
}
placeholder
=
"用户名"
onChange
=
{()
=>
{
this
.
props
.
dispatch
({
type
:
'login/setStatus'
,
payload
:
'login'
});
}}
/>
,
)
)
}
}
<
/Form.Item
>
<
/Form.Item
>
...
@@ -175,10 +184,4 @@ const mapStateToProps = ({ login, loading }) => {
...
@@ -175,10 +184,4 @@ const mapStateToProps = ({ login, loading }) => {
};
};
};
};
export
default
connect
(
mapStateToProps
)(
Form
.
create
({
export
default
connect
(
mapStateToProps
)(
Form
.
create
()(
LoginForm
));
onValuesChange
:
(
props
,
values
)
=>
{
if
(
values
.
userName
)
{
props
.
dispatch
({
type
:
'login/setStatus'
,
payload
:
'login'
});
}
},
})(
LoginForm
));
src/utils/auth.js
浏览文件 @
c678dd1e
...
@@ -60,13 +60,19 @@ export async function hasDomain() {
...
@@ -60,13 +60,19 @@ export async function hasDomain() {
return
getDomain
().
then
(
result
=>
!!
result
);
return
getDomain
().
then
(
result
=>
!!
result
);
}
}
const
normHistory
=
(
history
)
=>
{
const
normHistory
=
(
history
,
size
)
=>
{
if
(
!
history
)
{
if
(
!
history
)
{
history
=
{};
history
=
{};
}
}
if
(
!
history
.
size
)
{
if
(
!
history
.
size
)
{
if
(
size
)
{
history
.
size
=
size
;
}
else
{
history
.
size
=
10
;
history
.
size
=
10
;
}
}
}
else
if
(
size
&&
history
.
size
!==
size
)
{
history
.
size
=
size
;
}
if
(
history
.
size
<
1
)
{
if
(
history
.
size
<
1
)
{
history
.
size
=
1
;
history
.
size
=
1
;
}
}
...
@@ -112,16 +118,15 @@ export const histories = {
...
@@ -112,16 +118,15 @@ export const histories = {
},
},
async
createHistory
(
name
,
size
)
{
async
createHistory
(
name
,
size
)
{
let
history
=
db
.
get
(
`history.
${
name
}
`
).
value
();
let
history
=
db
.
get
(
`history.
${
name
}
`
).
value
();
history
=
normHistory
(
history
);
history
=
normHistory
(
history
,
size
);
history
.
size
=
size
;
return
db
.
set
(
`history.
${
name
}
`
,
history
).
write
();
return
db
.
set
(
`history.
${
name
}
`
,
history
).
write
();
},
},
async
destroyHistory
(
name
)
{
async
destroyHistory
(
name
)
{
return
db
.
unset
(
`history.
${
name
}
`
).
write
();
return
db
.
unset
(
`history.
${
name
}
`
).
write
();
},
},
async
getHistory
(
name
)
{
async
getHistory
(
name
,
size
)
{
let
history
=
db
.
get
(
`history.
${
name
}
`
).
value
();
let
history
=
db
.
get
(
`history.
${
name
}
`
).
value
();
history
=
normHistory
(
history
);
history
=
normHistory
(
history
,
size
);
if
(
history
.
empty
)
{
if
(
history
.
empty
)
{
return
[];
return
[];
}
else
if
(
history
.
top
>
history
.
start
)
{
}
else
if
(
history
.
top
>
history
.
start
)
{
...
@@ -130,9 +135,9 @@ export const histories = {
...
@@ -130,9 +135,9 @@ export const histories = {
return
[...
history
.
data
.
slice
(
history
.
start
,
history
.
size
),
...
history
.
data
.
slice
(
0
,
history
.
top
)];
return
[...
history
.
data
.
slice
(
history
.
start
,
history
.
size
),
...
history
.
data
.
slice
(
0
,
history
.
top
)];
}
}
},
},
async
pushHistory
(
name
,
value
)
{
async
pushHistory
(
name
,
value
,
size
)
{
let
history
=
await
db
.
get
(
`history.
${
name
}
`
).
value
();
let
history
=
await
db
.
get
(
`history.
${
name
}
`
).
value
();
history
=
normHistory
(
history
);
history
=
normHistory
(
history
,
size
);
history
.
data
[
history
.
top
]
=
value
;
history
.
data
[
history
.
top
]
=
value
;
const
nextPos
=
next
(
history
.
top
,
history
.
size
);
const
nextPos
=
next
(
history
.
top
,
history
.
size
);
if
(
!
history
.
empty
&&
history
.
start
===
history
.
top
)
{
if
(
!
history
.
empty
&&
history
.
start
===
history
.
top
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论