Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
疯人忠
Cvat
提交
6a779a79
C
Cvat
项目概览
疯人忠
/
Cvat
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cvat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6a779a79
编写于
12月 07, 2020
作者:
B
Boris Sekachev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Login with next, alternative implementation
上级
e5356cd8
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
35 addition
and
15 deletion
+35
-15
cvat-ui/src/actions/auth-actions.ts
cvat-ui/src/actions/auth-actions.ts
+5
-3
cvat-ui/src/components/cvat-app.tsx
cvat-ui/src/components/cvat-app.tsx
+9
-3
cvat-ui/src/components/login-page/login-page.tsx
cvat-ui/src/components/login-page/login-page.tsx
+8
-3
cvat-ui/src/components/login-with-token/login-with-token.tsx
cvat-ui/src/components/login-with-token/login-with-token.tsx
+5
-3
cvat-ui/src/index.tsx
cvat-ui/src/index.tsx
+2
-0
cvat-ui/src/reducers/auth-reducer.ts
cvat-ui/src/reducers/auth-reducer.ts
+5
-3
cvat-ui/src/reducers/interfaces.ts
cvat-ui/src/reducers/interfaces.ts
+1
-0
未找到文件。
cvat-ui/src/actions/auth-actions.ts
浏览文件 @
6a779a79
...
...
@@ -40,7 +40,7 @@ export const authActions = {
authorizeSuccess
:
(
user
:
any
)
=>
createAction
(
AuthActionTypes
.
AUTHORIZED_SUCCESS
,
{
user
}),
authorizeFailed
:
(
error
:
any
)
=>
createAction
(
AuthActionTypes
.
AUTHORIZED_FAILED
,
{
error
}),
login
:
()
=>
createAction
(
AuthActionTypes
.
LOGIN
),
loginSuccess
:
(
user
:
any
)
=>
createAction
(
AuthActionTypes
.
LOGIN_SUCCESS
,
{
user
}),
loginSuccess
:
(
user
:
any
,
next
:
string
|
null
)
=>
createAction
(
AuthActionTypes
.
LOGIN_SUCCESS
,
{
user
,
next
}),
loginFailed
:
(
error
:
any
)
=>
createAction
(
AuthActionTypes
.
LOGIN_FAILED
,
{
error
}),
register
:
()
=>
createAction
(
AuthActionTypes
.
REGISTER
),
registerSuccess
:
(
user
:
any
)
=>
createAction
(
AuthActionTypes
.
REGISTER_SUCCESS
,
{
user
}),
...
...
@@ -98,14 +98,16 @@ export const registerAsync = (
}
};
export
const
loginAsync
=
(
username
:
string
,
password
:
string
):
ThunkAction
=>
async
(
dispatch
)
=>
{
export
const
loginAsync
=
(
username
:
string
,
password
:
string
,
next
:
string
|
null
):
ThunkAction
=>
async
(
dispatch
,
)
=>
{
dispatch
(
authActions
.
login
());
try
{
await
cvat
.
server
.
login
(
username
,
password
);
const
users
=
await
cvat
.
users
.
get
({
self
:
true
});
dispatch
(
authActions
.
loginSuccess
(
users
[
0
]));
dispatch
(
authActions
.
loginSuccess
(
users
[
0
]
,
next
));
}
catch
(
error
)
{
dispatch
(
authActions
.
loginFailed
(
error
));
}
...
...
cvat-ui/src/components/cvat-app.tsx
浏览文件 @
6a779a79
...
...
@@ -64,6 +64,7 @@ interface CVATAppProps {
authActionsInitialized
:
boolean
;
notifications
:
NotificationsState
;
user
:
any
;
next
:
string
|
null
;
isModelPluginActive
:
boolean
;
}
...
...
@@ -231,16 +232,19 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
aboutInitialized
,
pluginsInitialized
,
formatsInitialized
,
modelsInitialized
,
switchShortcutsDialog
,
switchSettingsDialog
,
user
,
next
,
keyMap
,
location
,
isModelPluginActive
,
}
=
this
.
props
;
const
readyForRender
=
(
userInitialized
&&
(
user
==
null
||
!
user
.
isVerified
))
||
(
userInitialized
&&
formatsInitialized
&&
pluginsInitialized
&&
aboutInitialized
);
(
userInitialized
&&
formatsInitialized
&&
pluginsInitialized
&&
aboutInitialized
&&
modelsInitialized
);
const
subKeyMap
=
{
SWITCH_SHORTCUTS
:
keyMap
.
SWITCH_SHORTCUTS
,
...
...
@@ -310,7 +314,7 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
{
isModelPluginActive
&&
(
<
Route
exact
path
=
'/models'
component
=
{
ModelsPageContainer
}
/>
)
}
<
Redirect
push
to
=
'/tasks'
/>
<
Redirect
push
to
=
{
next
||
'
/tasks
'
}
/>
</
Switch
>
</
GlobalHotKeys
>
{
/* eslint-disable-next-line */
}
...
...
@@ -337,7 +341,9 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
path
=
'/auth/password/reset/confirm'
component
=
{
ResetPasswordPageConfirmComponent
}
/>
<
Redirect
to
=
'/auth/login'
/>
<
Redirect
to
=
{
location
.
pathname
.
length
>
1
?
`/auth/login/?next=
${
location
.
pathname
}
`
:
'
/auth/login
'
}
/>
</
Switch
>
</
GlobalErrorBoundary
>
);
...
...
cvat-ui/src/components/login-page/login-page.tsx
浏览文件 @
6a779a79
...
...
@@ -15,7 +15,8 @@ import CookieDrawer from './cookie-policy-drawer';
interface
LoginPageComponentProps
{
fetching
:
boolean
;
renderResetPassword
:
boolean
;
onLogin
:
(
username
:
string
,
password
:
string
)
=>
void
;
next
:
string
;
onLogin
:
(
username
:
string
,
password
:
string
,
next
:
string
|
null
)
=>
void
;
}
function
LoginPageComponent
(
props
:
LoginPageComponentProps
&
RouteComponentProps
):
JSX
.
Element
{
...
...
@@ -27,7 +28,11 @@ function LoginPageComponent(props: LoginPageComponentProps & RouteComponentProps
xl
:
{
span
:
4
},
};
const
{
fetching
,
onLogin
,
renderResetPassword
}
=
props
;
const
{
fetching
,
onLogin
,
renderResetPassword
,
location
,
}
=
props
;
const
search
=
new
URLSearchParams
(
location
.
search
);
return
(
<>
...
...
@@ -37,7 +42,7 @@ function LoginPageComponent(props: LoginPageComponentProps & RouteComponentProps
<
LoginForm
fetching
=
{
fetching
}
onSubmit
=
{
(
loginData
:
LoginData
):
void
=>
{
onLogin
(
loginData
.
username
,
loginData
.
password
);
onLogin
(
loginData
.
username
,
loginData
.
password
,
search
.
get
(
'
next
'
)
);
}
}
/>
<
Row
type
=
'flex'
justify
=
'start'
align
=
'top'
>
...
...
cvat-ui/src/components/login-with-token/login-with-token.tsx
浏览文件 @
6a779a79
...
...
@@ -3,15 +3,17 @@
// SPDX-License-Identifier: MIT
import
React
,
{
useEffect
}
from
'
react
'
;
import
{
Redirect
,
useParams
}
from
'
react-router
'
;
import
{
Redirect
,
useParams
,
useLocation
}
from
'
react-router
'
;
import
{
useCookies
}
from
'
react-cookie
'
;
export
default
function
LoginWithTokenComponent
():
JSX
.
Element
{
const
{
sessionId
,
token
}
=
useParams
();
const
location
=
useLocation
();
const
{
sessionId
,
token
}
=
useParams
<
{
sessionId
:
string
;
token
:
string
}
>
();
const
[
cookies
,
setCookie
]
=
useCookies
([
'
sessionid
'
,
'
csrftoken
'
]);
const
expires1y
=
new
Date
(
new
Date
().
setFullYear
(
new
Date
().
getFullYear
()
+
1
));
const
expires2w
=
new
Date
(
new
Date
().
setDate
(
new
Date
().
getDate
()
+
13
));
const
search
=
new
URLSearchParams
(
location
.
search
);
setCookie
(
'
sessionid
'
,
sessionId
,
{
path
:
'
/
'
,
expires
:
expires2w
});
setCookie
(
'
csrftoken
'
,
token
,
{
path
:
'
/
'
,
expires
:
expires1y
});
...
...
@@ -24,7 +26,7 @@ export default function LoginWithTokenComponent(): JSX.Element {
);
if
(
cookies
.
sessionid
&&
cookies
.
csrftoken
)
{
return
<
Redirect
to
=
'/tasks'
/>;
return
<
Redirect
to
=
{
search
.
has
(
'
next
'
)
?
(
search
.
get
(
'
next
'
)
as
string
)
:
'
/tasks
'
}
/>;
}
return
<></>;
}
cvat-ui/src/index.tsx
浏览文件 @
6a779a79
...
...
@@ -45,6 +45,7 @@ interface StateToProps {
allowResetPassword
:
boolean
;
notifications
:
NotificationsState
;
user
:
any
;
next
:
string
|
null
;
keyMap
:
Record
<
string
,
ExtendedKeyMapOptions
>
;
isModelPluginActive
:
boolean
;
}
...
...
@@ -91,6 +92,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
allowResetPassword
:
auth
.
allowResetPassword
,
notifications
:
state
.
notifications
,
user
:
auth
.
user
,
next
:
auth
.
next
,
keyMap
:
shortcuts
.
keyMap
,
isModelPluginActive
:
plugins
.
list
.
MODELS
,
};
...
...
cvat-ui/src/reducers/auth-reducer.ts
浏览文件 @
6a779a79
...
...
@@ -10,6 +10,7 @@ const defaultState: AuthState = {
initialized
:
false
,
fetching
:
false
,
user
:
null
,
next
:
null
,
authActionsFetching
:
false
,
authActionsInitialized
:
false
,
allowChangePassword
:
false
,
...
...
@@ -40,6 +41,7 @@ export default function (state = defaultState, action: AuthActions | BoundariesA
...
state
,
fetching
:
false
,
user
:
action
.
payload
.
user
,
next
:
action
.
payload
.
next
,
};
case
AuthActionTypes
.
LOGIN_FAILED
:
return
{
...
...
@@ -94,9 +96,9 @@ export default function (state = defaultState, action: AuthActions | BoundariesA
return
{
...
state
,
showChangePasswordDialog
:
typeof
action
.
payload
.
showChangePasswordDialog
===
'
undefined
'
?
!
state
.
showChangePasswordDialog
:
action
.
payload
.
showChangePasswordDialog
,
typeof
action
.
payload
.
showChangePasswordDialog
===
'
undefined
'
?
!
state
.
showChangePasswordDialog
:
action
.
payload
.
showChangePasswordDialog
,
};
case
AuthActionTypes
.
REQUEST_PASSWORD_RESET
:
return
{
...
...
cvat-ui/src/reducers/interfaces.ts
浏览文件 @
6a779a79
...
...
@@ -14,6 +14,7 @@ export interface AuthState {
initialized
:
boolean
;
fetching
:
boolean
;
user
:
any
;
next
:
string
|
null
;
authActionsFetching
:
boolean
;
authActionsInitialized
:
boolean
;
showChangePasswordDialog
:
boolean
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录