Skip to content

Commit

Permalink
add a frontend route definition that requires logging in
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleBaiBai committed Feb 13, 2020
1 parent 294a1ad commit b33247c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion backend/gateway-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"sso-enabled": true
},
{
"path": "/api/animals/*/adoption-requests/**",
"path": "/api/animals/*/adoption-requests/**"
}
]
}
2 changes: 1 addition & 1 deletion backend/src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ insert into animal (id, name, rescue_date, avatar_url, description) values
(6, 'Ginger', '2020-01-12', 'https://cdn.pixabay.com/photo/2015/12/29/20/51/dog-1113398_960_720.jpg', 'Ginger is a posh Pomeranian that loves to be pampered by her humans.'),
(7, 'Whiskers', '2020-01-20', 'https://cdn.pixabay.com/photo/2017/01/20/21/22/kitten-asleep-in-a-pot-1995961_960_720.jpg', 'Whiskers is a sweet and loving little kitten. She loves cuddling with her humans.'),
(8, 'Mittens', '2020-01-22', 'https://cdn.pixabay.com/photo/2013/05/17/15/54/cat-111793_960_720.jpg', 'Mittens is a chubby cat that loves spending his days lounging and eating catnip.'),
(9, 'Sabrina', '2020-01-24', 'https://cdn.pixabay.com/photo/2016/11/29/01/10/adorable-1866475_960_720.jpg', 'Sabrina is a friendly kitten qith beautify blue eyes. She does not need lots of attention, but loves a good belly rub.'),
(9, 'Sabrina', '2020-01-24', 'https://cdn.pixabay.com/photo/2016/11/29/01/10/adorable-1866475_960_720.jpg', 'Sabrina is a friendly kitten with beautify blue eyes. She does not need lots of attention, but loves a good belly rub.'),
(10, 'Georgie', '2020-01-29', 'https://cdn.pixabay.com/photo/2017/03/14/19/06/bulldog-2144110_960_720.jpg', 'Georgie will slobber all over you with his kisses. Does not require a lot of physical activity.');

insert into adoption_request (id, animal, adopter_name, email, notes) values
Expand Down
9 changes: 5 additions & 4 deletions frontend/gateway-config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"routes": [
{
"path": "/rescue/**"
},
{
"path": "/rescue/admin/**",
"path": "/rescue/admin",
"filters": ["StripPrefix=2"],
"sso-enabled": true,
"token-relay": true
},
{
"path": "/rescue/**"
}
]
}
28 changes: 15 additions & 13 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import './App.css';
import AnimalCards from "./components/animal-cards";
import {Button} from "semantic-ui-react";
import {Button, ButtonGroup} from "semantic-ui-react";
import HttpClient from "./httpClient";

export default class App extends React.Component {
Expand All @@ -23,18 +23,20 @@ export default class App extends React.Component {
<p>
Animal Rescue Center
</p>
<Button animated='fade' href={'/oauth2/authorization/sso'}>
<Button.Content visible>Sign in to adopt</Button.Content>
<Button.Content hidden>It only takes a loving heart!</Button.Content>
</Button>
<Button animated='fade' onClick={this.signIn}>
<Button.Content visible>Who am I?</Button.Content>
<Button.Content hidden>Click to see!</Button.Content>
</Button>
<Button animated='fade' href={'/rescue/admin'}>
<Button.Content visible>Admin view</Button.Content>
<Button.Content hidden>Same app but requires login</Button.Content>
</Button>
<ButtonGroup>
<Button animated='fade' color='red' href={'/oauth2/authorization/sso'}>
<Button.Content visible>Sign in to adopt</Button.Content>
<Button.Content hidden>Redirect back to / by design</Button.Content>
</Button>
<Button animated='fade' color='black' onClick={this.signIn}>
<Button.Content visible>Who am I?</Button.Content>
<Button.Content hidden>XHR doesn't handle redirect correctly</Button.Content>
</Button>
<Button animated='fade' color='green' href={'/rescue/admin'}>
<Button.Content visible>Admin view</Button.Content>
<Button.Content hidden>Same app but requires login</Button.Content>
</Button>
</ButtonGroup>
</header>
<div className={"App-body"}>
<AnimalCards/>
Expand Down

0 comments on commit b33247c

Please sign in to comment.