-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to login into UI with token from api/v1/auth/login #2234
Changes from 3 commits
486e6d6
c0a129f
01db6f0
86dde89
0a2bb4a
602d409
5748e9b
161f3e3
6ddf120
4b3e017
424c4b9
24ceb3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2020 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React from 'react'; | ||
import {Redirect, useParams} from "react-router"; | ||
import {useCookies } from "react-cookie"; | ||
tdowgiel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default function LoginWithTokenComponent(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, add return type for the function |
||
const { sessionId, token } = useParams() | ||
const [cookies, setCookie] = useCookies(['sessionid', 'csrftoken']) | ||
const expires = new Date(new Date().setFullYear(new Date().getFullYear() + 1)) | ||
bsekachev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
setCookie('sessionid', sessionId, {path: '/', expires }) | ||
setCookie('csrftoken', token, {path: '/', expires}) | ||
tdowgiel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if ( cookies['sessionid'] && cookies['csrftoken']) { | ||
window.location.reload(); | ||
<Redirect to="/tasks" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose redirect after reload is useless. Moreover it should be wrapped into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason. I need to reload window to apply this changes. However, i have fixed issue with endless reloading when wrong token, by moving this to useEffect |
||
} | ||
return(<></>); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use absolute import:
components/login-with-token/login-with-token
, or put the line after all absolute (linter says that relative import should occur after absolute)