Skip to content

Commit de49bbf

Browse files
committed
Integrate app into main website, various improvements
1 parent e73429e commit de49bbf

23 files changed

+264
-93
lines changed

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"start": "parcel public/index.html",
9-
"build": "parcel build --experimental-scope-hoisting public/**/*",
8+
"start": "parcel verify.html",
9+
"build-test": "parcel build --experimental-scope-hoisting verify.html",
10+
"build-prod": "parcel build --experimental-scope-hoisting --public-url /verify --out-dir ../public/verify src/index.js",
1011
"format": "prettier --write src/**/*.{css,js} public/**/*.{html,js}"
1112
},
1213
"repository": {

public/favicon.ico

-15 KB
Binary file not shown.

public/index.html

-12
This file was deleted.

public/robots.txt

-2
This file was deleted.

public/well-known/microsoft-identity-association.json

-7
This file was deleted.

src/Accounts/Steam.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,30 @@ import "./Steam.css";
99
export default function Steam({ data }) {
1010
const params = new URLSearchParams({
1111
"openid.mode": "checkid_setup",
12-
"openid.return_to": LOCATION + "/auth/steam",
12+
"openid.return_to": LOCATION + "/verify/steam",
1313
"openid.ns": "http://specs.openid.net/auth/2.0",
1414
"openid.claimed_id": "http://specs.openid.net/auth/2.0/identifier_select",
1515
"openid.identity": "http://specs.openid.net/auth/2.0/identifier_select",
1616
});
1717

18+
const cls = data ? "connect" : "connect bold";
19+
const name = data ? (
20+
<a className="account" href={`https://steamcommunity.com/profiles/${data.id}`} target="_blank">
21+
{data.name}
22+
</a>
23+
) : (
24+
"Not Connected"
25+
);
26+
1827
const url = "https://steamcommunity.com/openid/login?" + params.toString();
1928

2029
return (
2130
<>
2231
<img title="Steam" src={SteamIcon} />
23-
<div>{data ? data.name : "Not Connected"}</div>
24-
<a href={url}>{data ? "Change Account" : "Connect Account"}</a>
32+
<div>{name}</div>
33+
<a className={cls} href={url}>
34+
{data ? "Change Account" : "Connect Account"}
35+
</a>
2536
</>
2637
);
2738
}

src/Accounts/Xbox.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,34 @@ export default function Xbox({ data }) {
1010
const params = new URLSearchParams({
1111
client_id: MICROSOFT_CLIENT_ID,
1212
response_type: "code",
13-
redirect_uri: LOCATION + "/auth/xbox",
13+
redirect_uri: LOCATION + "/verify/xbox",
1414
scope: "xboxlive.signin offline_access",
1515
response_mode: "query",
1616
prompt: "consent",
1717
});
1818

19+
const cls = data ? "connect" : "connect bold";
20+
const name = data ? (
21+
<a
22+
className="account"
23+
href={`https://account.xbox.com/en-us/profile?gamertag=${data.name}`}
24+
target="_blank"
25+
>
26+
{data.name}
27+
</a>
28+
) : (
29+
"Not Connected"
30+
);
31+
1932
const url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?" + params.toString();
33+
2034
return (
2135
<>
2236
<img title="Xbox" src={XboxIcon} />
23-
<div>{data ? data.name : "Not Connected"}</div>
24-
<a href={url}>{data ? "Change Account" : "Connect Account"}</a>
37+
<div>{name}</div>
38+
<a className={cls} href={url}>
39+
{data ? "Change Account" : "Connect Account"}
40+
</a>
2541
</>
2642
);
2743
}

src/Accounts/index.css

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.user {
22
margin-top: 1em;
3-
margin-bottom: -1em;
3+
margin-bottom: 1em;
44
text-align: center;
55
}
66

@@ -30,10 +30,16 @@
3030
}
3131

3232
.platform div {
33+
color: white;
3334
padding-left: 1em;
3435
}
3536

36-
.platform a {
37+
.platform .account {
38+
color: white;
39+
border-bottom: 1px solid white;
40+
}
41+
42+
.platform .connect {
3743
float: right;
3844
background-color: #0062cc;
3945

@@ -42,7 +48,17 @@
4248
color: white;
4349
}
4450

51+
.bold {
52+
font-weight: bold;
53+
}
54+
4555
h3 {
46-
margin-top: 2em;
56+
display: block;
57+
margin-top: 1em;
58+
margin-bottom: 0;
4759
text-align: center;
4860
}
61+
62+
.accounts p {
63+
margin-top: 0;
64+
}

src/Accounts/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ function LogoutButton({ updateUser }) {
2222

2323
export default function Accounts({ user, updateUser }) {
2424
return (
25-
<div>
25+
<div className="accounts">
2626
<Avatar user={user} />
2727
<div className="user">
2828
Logged in as {user.name}#{user.discriminator}<LogoutButton updateUser={updateUser} />
2929
</div>
30-
<div className="divider" />
30+
3131
<div className="platform steam">
3232
<Steam data={user.connections.steam} />
3333
</div>
3434
<div className="platform xbox">
3535
<Xbox data={user.connections.xbox} />
3636
</div>
37+
3738
<h3>Is your platform not available?</h3>
3839
<p>Get in contact with 100Pals Staff and let us know!</p>
3940
</div>

src/App.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ export default function App() {
1313
return (
1414
<BrowserRouter>
1515
<Switch>
16-
<Route exact path="/">
17-
<Redirect to="/home" />
18-
</Route>
19-
<Route path="/home">
16+
<Route exact path="/verify">
2017
<MenuBase />
2118
</Route>
22-
<Route path="/auth">
19+
<Route path="/verify/*">
2320
<CallbackHandler />
2421
</Route>
2522
</Switch>
@@ -62,7 +59,7 @@ class MenuBase extends Component {
6259

6360
return (
6461
<div className="menu">
65-
<h1>AchievementHunting.com Verification</h1>
62+
<h1>Account Verification</h1>
6663
{user ? <Accounts user={user} updateUser={this.updateUser} /> : <Landing />}
6764
</div>
6865
);

src/Callback.js

+19-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { Redirect, withRouter } from "react-router-dom";
33

44
import api, { APIError } from "./api";
55
import { AppFailure, Loading } from "./Common";
6+
import Reminder from "./Reminder";
67

78
class CallbackHandler extends Component {
89
constructor(props) {
910
super(props);
1011

11-
this.state = { loading: true, error: null };
12+
this.reminderSeen = this.reminderSeen.bind(this);
13+
this.state = { loading: true, error: null, steam: null };
1214
}
1315

1416
async componentDidMount() {
@@ -21,26 +23,31 @@ class CallbackHandler extends Component {
2123
this.setState({ loading: false });
2224
}
2325

26+
async reminderSeen() {
27+
this.setState({ steam: null });
28+
}
29+
2430
async processData() {
2531
const path = this.props.location.pathname;
2632
const search = new URLSearchParams(this.props.location.search);
2733

2834
// The Discord and Xbox auth flow can be cancelled
29-
// In this case the user is redirected back to /app
35+
// In this case the user is redirected back to /verify
3036
switch (path) {
31-
case "/auth/discord": {
37+
case "/verify/discord": {
3238
const code = search.get("code");
3339

3440
if (code) {
3541
await api.login(code);
3642
}
3743
break;
3844
}
39-
case "/auth/steam": {
40-
await api.createSteamConnection(Object.fromEntries(search));
45+
case "/verify/steam": {
46+
const data = await api.createSteamConnection(Object.fromEntries(search));
47+
this.setState({ steam: data });
4148
break;
4249
}
43-
case "/auth/xbox": {
50+
case "/verify/xbox": {
4451
const code = search.get("code");
4552

4653
if (code) {
@@ -55,13 +62,17 @@ class CallbackHandler extends Component {
5562
}
5663

5764
render() {
58-
const { loading, error } = this.state;
65+
const { loading, error, steam } = this.state;
5966

6067
if (error) {
6168
return <AppFailure error={error} />;
6269
}
6370

64-
return loading ? <Loading /> : <Redirect to="/home" />;
71+
if (steam && steam.status === "private") {
72+
return <Reminder id={steam.id} reminderSeen={this.reminderSeen} />;
73+
}
74+
75+
return loading ? <Loading /> : <Redirect to="/verify" />;
6576
}
6677
}
6778

src/Common.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import { Link } from "react-router-dom";
23

34
import "./common.css";
45

@@ -8,5 +9,12 @@ export function Loading() {
89

910
export function AppFailure({ error }) {
1011
const _default = "Something unexpected went wrong. Try again later.";
11-
return <h1 className="status error">{error.message ?? _default}</h1>;
12+
return (
13+
<>
14+
<h1 className="status error">{error.message ?? _default}</h1>
15+
<div className="wrap-return">
16+
<Link to="/verify">Go Back to account verification</Link>
17+
</div>
18+
</>
19+
);
1220
}

src/Landing.css

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
p {
2+
margin-top: 1em;
3+
}
4+
15
p,
26
.login {
37
text-align: center;
48
}
59

610
.login {
7-
margin-top: 30%;
11+
padding: 1em;
812
}
913

1014
.login a {
11-
font-size: x-large;
12-
padding: 10px;
15+
font-size: large;
16+
padding: 5px;
1317
border-radius: 5px;
1418
color: white;
1519
background-color: #0062cc;

src/Landing.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import "./Landing.css";
99
export default function Landing() {
1010
const params = new URLSearchParams({
1111
client_id: DISCORD_CLIENT_ID,
12-
redirect_uri: LOCATION + "/auth/discord",
12+
redirect_uri: LOCATION + "/verify/discord",
1313
scope: "identify connections",
1414
response_type: "code",
1515
prompt: IS_LOCAL ? "none" : "consent", // Save some time clicking authorize :)
@@ -20,7 +20,6 @@ export default function Landing() {
2020
return (
2121
<>
2222
<img className="icon" src={SiteIcon} alt="AchievementHunting.com Icon" />
23-
<div className="divider" />
2423
<p>Sign in with Discord in order to start verifying ownership of your gaming accounts.</p>
2524
<p>You will be prompted to verify the platforms you play games on.</p>
2625
<div className="login">

src/Reminder.css

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.privacy-wrapper {
2+
max-width: 40em;
3+
display: block;
4+
margin: 0 auto;
5+
}
6+
7+
.privacy {
8+
max-width: 100%;
9+
}
10+
11+
.continue {
12+
padding-top: 1em;
13+
padding-bottom: 1em;
14+
text-align: center;
15+
}
16+
17+
.continue button {
18+
border: none;
19+
background: none;
20+
text-decoration: underline;
21+
cursor: pointer;
22+
font-size: large;
23+
padding: 0;
24+
color: #8bd;
25+
}

0 commit comments

Comments
 (0)