Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #88 from davidradl/git41
Browse files Browse the repository at this point in the history
#41 handle untentanted url
  • Loading branch information
davidradl authored Feb 23, 2021
2 parents 7f343a8 + 4d24b72 commit d69bfb6
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cra-client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from "react";
import "./app.scss";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Login from "./auth/login";
import NoServerName from "./auth/NoServerName";
import Frame from "./Frame";
import IdentificationContext from "./contexts/IdentificationContext";

Expand All @@ -13,6 +14,9 @@ export default function App() {
<IdentificationContext>
<Router>
<Switch>
<Route path="/" exact>
<NoServerName/>
</Route>
<Route path="/*/login" exact>
<Login currentURL={window.location.href} />
</Route>
Expand Down
64 changes: 64 additions & 0 deletions cra-client/src/auth/NoServerName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright Contributors to the ODPi Egeria project. */
import React, {useState} from "react";
import "./Login.css";
import Egeriacolor from "../images/odpi/Egeria_logo_color";

import {
Grid,
Row,
Column,
Form,
FormGroup,
TextInput
} from "carbon-components-react";

const NoServerName = () => {
const [serverName, setServerName] = useState("");

const handleOnChange = (event) => {
const value = event.target.value;
setServerName(value);
console.log("handleOnChange :" + value);
};

const validateForm = () => {
return serverName && serverName.length > 0;
};

return (
<div>
<Egeriacolor />
<div>Please supply a server name:</div>
<Grid>
<Row>
<Column
sm={{ span: 4 }}
md={{ span: 4, offset: 2 }}
lg={{ span: 4, offset: 6 }}
>
<Form id="egeria-login-form">
<FormGroup legendText="">
<TextInput
type="text"
labelText="Server Name"
id="server-name"
name="serverName"
value={serverName}
onChange={handleOnChange}
placeholder="Server Name"
required
/>
</FormGroup>
{validateForm() && (
<a href={serverName}>Login with server name {serverName}</a>
)}
</Form>
</Column>
</Row>
</Grid>
</div>
);
};

export default NoServerName;
1 change: 0 additions & 1 deletion cra-client/src/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const Login = () => {
} else {
setErrorMsg("Login Failed");
}
setErrorMsg("Login Failed with " + res);
}
})
.catch(res => {
Expand Down

0 comments on commit d69bfb6

Please sign in to comment.