diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index 56faf4402b..b4d01e067b 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -14,14 +14,9 @@ * limitations under the License. */ -import { - createApp, - AlertDisplay, - OAuthRequestDialog, - LoginPage, -} from '@backstage/core'; +import { createApp, AlertDisplay, OAuthRequestDialog } from '@backstage/core'; import React, { FC } from 'react'; -import { BrowserRouter as Router, Route } from 'react-router-dom'; +import { BrowserRouter as Router } from 'react-router-dom'; import Root from './components/Root'; import * as plugins from './plugins'; import apis from './apis'; @@ -40,7 +35,6 @@ const App: FC<{}> = () => ( - diff --git a/packages/core/src/layout/LoginPage/LoginPage.tsx b/packages/core/src/layout/LoginPage/LoginPage.tsx deleted file mode 100644 index 7bf14dba01..0000000000 --- a/packages/core/src/layout/LoginPage/LoginPage.tsx +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import React, { FC, useState } from 'react'; -import GitHubIcon from '@material-ui/icons/GitHub'; -import { Page } from '../Page'; -import { Header } from '../Header'; -import { Content } from '../Content'; -import { ContentHeader } from '../ContentHeader'; -import { InfoCard } from '../InfoCard/InfoCard'; -import { - Grid, - Typography, - Button, - TextField, - List, - ListItem, - Link, -} from '@material-ui/core'; - -enum AuthType { - GitHub, -} - -export const LoginPage: FC<{}> = () => { - const [githubUsername, setGithubUsername] = useState(String); - const [githubPersonalAuthToken, setGithubPersonalAuthToken] = useState( - String, - ); - const [loginDetails, setLoginDetails] = useState(Object); - - const saveGithubInfo = (info: {}) => { - localStorage.setItem('githubLoginDetails', JSON.stringify(info)); - setLoginDetails(info); - }; - - const deleteGithubInfo = () => { - localStorage.removeItem('githubLoginDetails'); - setLoginDetails(undefined); - }; - - const handleTokenRegistration = (event: any) => { - switch (event.target.name) { - case 'github-username-tf': - setGithubUsername(event.target.value); - break; - case 'github-auth-tf': - setGithubPersonalAuthToken(event.target.value); - break; - default: - break; - } - }; - - const fetchGitHubToken = (username: String, token: String) => { - fetch('https://api.github.com/user', { - headers: new Headers({ - Authorization: `Basic ${btoa(`${username}:${token}`)}`, - 'Content-Type': 'application/x-www-form-urlencoded', - }), - }) - .then(response => { - if (response.status === 200) return response.json(); - throw Error(`${response.status} ${response.statusText}`); - }) - .then(data => { - const info = { - username: username, - token: token, - name: data.name || data.login, - }; - saveGithubInfo(info); - }) - .catch(() => {}); - }; - - const validateUsernameAndToken = (username: String, token: String) => { - if (username === undefined || username === null || username === '') - return false; - - if (token === undefined || token === null || token === '') return false; - - return true; - }; - - const authenticate = (type: AuthType) => { - switch (type) { - case AuthType.GitHub: - { - const username = githubUsername; - const token = githubPersonalAuthToken; - if (validateUsernameAndToken(username, token)) - fetchGitHubToken(username, token); - } - break; - default: - break; - } - }; - - const LoginIndicator = () => { - const ls = localStorage.getItem('githubLoginDetails'); - if (ls !== null) { - const obj = ls || loginDetails ? JSON.parse(ls) : loginDetails; - return ( - - {`Welcome, ${obj.name}!`} -
- Logout -
- ); - } - return ( - - Welcome, guest! - - ); - }; - - return ( - -
- -
- - - - - - - GitHub - - - - - - - - - - - - - - - - -
- ); -}; diff --git a/packages/core/src/layout/LoginPage/index.ts b/packages/core/src/layout/LoginPage/index.ts deleted file mode 100644 index caa94bd6d7..0000000000 --- a/packages/core/src/layout/LoginPage/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { LoginPage } from './LoginPage'; diff --git a/packages/core/src/layout/index.ts b/packages/core/src/layout/index.ts index c9dbae9ca2..e8341e1124 100644 --- a/packages/core/src/layout/index.ts +++ b/packages/core/src/layout/index.ts @@ -21,7 +21,6 @@ export * from './Header'; export * from './HeaderLabel'; export * from './HomepageTimer'; export * from './InfoCard'; -export * from './LoginPage'; export * from './Page'; export * from './Sidebar'; export * from './TabbedCard';