Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
557384e6
Unverified
Commit
557384e6
authored
Mar 07, 2024
by
Zzm0809
Committed by
GitHub
Mar 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix] Fix token may get empty and cause page crash (#3254)
Co-authored-by:
Zzm0809
<
Zzm0809@users.noreply.github.com
>
parent
ca5d7468
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
8 deletions
+15
-8
messages_en_US.properties
...-common/src/main/resources/i18n/messages_en_US.properties
+1
-1
messages_zh_CN.properties
...-common/src/main/resources/i18n/messages_zh_CN.properties
+1
-1
function.tsx
dinky-web/src/pages/Other/Login/function.tsx
+1
-1
index.tsx
dinky-web/src/pages/Other/Login/index.tsx
+12
-5
No files found.
dinky-common/src/main/resources/i18n/messages_en_US.properties
View file @
557384e6
...
@@ -35,7 +35,7 @@ test.msg.job.log.url=Click to view the exception log for this task
...
@@ -35,7 +35,7 @@ test.msg.job.log.url=Click to view the exception log for this task
user.assign.role.success
=
User Assign Role Success
user.assign.role.success
=
User Assign Role Success
global.params.check.error.value
=
Field: {0}, Illegal Value: {1}
global.params.check.error.value
=
Field: {0}, Illegal Value: {1}
change.password.success
=
Change Password Success
change.password.success
=
Change Password Success
user.not.exist
=
User
:{0}
Not Exist
user.not.exist
=
User Not Exist
refresh.success
=
Refresh Successfully
refresh.success
=
Refresh Successfully
ds.get.node.list.error
=
Get Node List Error
ds.get.node.list.error
=
Get Node List Error
ldap.default.tenant.nofound
=
The LDAP default tenant does not exist
ldap.default.tenant.nofound
=
The LDAP default tenant does not exist
...
...
dinky-common/src/main/resources/i18n/messages_zh_CN.properties
View file @
557384e6
...
@@ -35,7 +35,7 @@ test.msg.job.log.url=点击查看该任务的异常日志
...
@@ -35,7 +35,7 @@ test.msg.job.log.url=点击查看该任务的异常日志
user.assign.role.success
=
用户分配角色成功
user.assign.role.success
=
用户分配角色成功
global.params.check.error.value
=
字段: {0}, 不合法的值: {1}
global.params.check.error.value
=
字段: {0}, 不合法的值: {1}
change.password.success
=
修改密码成功
change.password.success
=
修改密码成功
user.not.exist
=
用户
:{0}
不存在
user.not.exist
=
用户不存在
refresh.success
=
刷新成功
refresh.success
=
刷新成功
ds.get.node.list.error
=
节点获取失败
ds.get.node.list.error
=
节点获取失败
ldap.default.tenant.nofound
=
LDAP默认租户不存在
ldap.default.tenant.nofound
=
LDAP默认租户不存在
...
...
dinky-web/src/pages/Other/Login/function.tsx
View file @
557384e6
...
@@ -36,7 +36,7 @@ export const gotoRedirectUrl = () => {
...
@@ -36,7 +36,7 @@ export const gotoRedirectUrl = () => {
export
const
redirectToLogin
=
()
=>
{
export
const
redirectToLogin
=
()
=>
{
//TODO: 弹出确认框
//TODO: 弹出确认框
window
.
location
.
href
=
'/login'
;
window
.
location
.
href
=
'/
user/
login'
;
};
};
export
const
initSomeThing
=
()
=>
{
export
const
initSomeThing
=
()
=>
{
...
...
dinky-web/src/pages/Other/Login/index.tsx
View file @
557384e6
...
@@ -24,7 +24,7 @@ import LangSwitch from '@/pages/Other/Login/LangSwitch';
...
@@ -24,7 +24,7 @@ import LangSwitch from '@/pages/Other/Login/LangSwitch';
import
{
chooseTenantSubmit
,
login
,
queryDataByParams
}
from
'@/services/BusinessCrud'
;
import
{
chooseTenantSubmit
,
login
,
queryDataByParams
}
from
'@/services/BusinessCrud'
;
import
{
API
}
from
'@/services/data'
;
import
{
API
}
from
'@/services/data'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
UserBaseInfo
}
from
'@/types/AuthCenter/data
'
;
import
{
SaTokenInfo
,
UserBaseInfo
}
from
'@/types/AuthCenter/data.d
'
;
import
{
setTenantStorageAndCookie
}
from
'@/utils/function'
;
import
{
setTenantStorageAndCookie
}
from
'@/utils/function'
;
import
{
useLocalStorage
}
from
'@/utils/hook/useLocalStorage'
;
import
{
useLocalStorage
}
from
'@/utils/hook/useLocalStorage'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
...
@@ -67,7 +67,8 @@ const Login: React.FC = () => {
...
@@ -67,7 +67,8 @@ const Login: React.FC = () => {
* When the token is expired, redirect to login
* When the token is expired, redirect to login
*/
*/
useEffect
(()
=>
{
useEffect
(()
=>
{
const
expirationTime
=
JSON
.
parse
(
JSON
.
stringify
(
localStorageOfToken
)).
tokenTimeout
??
0
;
// GET TOKEN TIMEOUT
const
expirationTime
=
(
JSON
.
parse
(
JSON
.
stringify
(
localStorageOfToken
))
as
SaTokenInfo
)?.
tokenTimeout
??
0
;
// GET TOKEN TIMEOUT
let
timeRemaining
=
0
;
let
timeRemaining
=
0
;
let
timer
:
NodeJS
.
Timeout
;
let
timer
:
NodeJS
.
Timeout
;
if
(
expirationTime
>
0
)
{
if
(
expirationTime
>
0
)
{
...
@@ -138,9 +139,15 @@ const Login: React.FC = () => {
...
@@ -138,9 +139,15 @@ const Login: React.FC = () => {
const
result
=
await
login
({
...
values
});
const
result
=
await
login
({
...
values
});
if
(
result
.
code
===
0
)
{
if
(
result
.
code
===
0
)
{
// if login success then get token info and set it to local storage
// if login success then get token info and set it to local storage
await
queryDataByParams
(
API_CONSTANTS
.
TOKEN_INFO
).
then
((
res
)
=>
await
queryDataByParams
<
SaTokenInfo
>
(
API_CONSTANTS
.
TOKEN_INFO
).
then
((
res
)
=>
{
setLocalStorageOfToken
(
JSON
.
stringify
(
res
))
console
.
log
(
res
);
);
if
(
res
)
{
setLocalStorageOfToken
(
JSON
.
stringify
(
res
));
}
else
{
// 如果没有获取到token信息,直接跳转到登录页
redirectToLogin
();
}
});
}
}
setInitialState
((
s
)
=>
({
...
s
,
currentUser
:
result
.
data
}));
setInitialState
((
s
)
=>
({
...
s
,
currentUser
:
result
.
data
}));
await
SuccessMessageAsync
(
l
(
'login.result'
,
''
,
{
msg
:
result
.
msg
,
time
:
result
.
time
}));
await
SuccessMessageAsync
(
l
(
'login.result'
,
''
,
{
msg
:
result
.
msg
,
time
:
result
.
time
}));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment