Skip to content

Commit 55d6715

Browse files
authored
Merge pull request #40 from hackclub/staging
Add hackatime trust error failed to fetch fix
2 parents 71a534a + 12734c7 commit 55d6715

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# DATABASE_URL=postgresql://postgres:password@db:5432/postgres
66
# PUBLIC_ENV=production # or staging
77
# PUBLIC_COMMIT=$SOURCE_COMMIT
8+
# RACK_ATTACK_BYPASS= # rate limit bypass
89

910
PUBLIC_ENV=dev
1011

src/routes/auth/callback/+server.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,22 @@ export async function GET(event) {
132132
// Check Hackatime trust
133133
const hackatimeTrust = (
134134
await (
135-
await fetch(`https://hackatime.hackclub.com/api/v1/users/${slack_id}/trust_factor`)
135+
await fetch(`https://hackatime.hackclub.com/api/v1/users/${slack_id}/trust_factor`, {
136+
headers: env.RACK_ATTACK_BYPASS
137+
? {
138+
RACK_ATTACK_BYPASS: env.RACK_ATTACK_BYPASS
139+
}
140+
: {}
141+
})
136142
).json()
137143
)['trust_level'];
138144

139145
if (!hackatimeTrust) {
140146
console.error();
141-
return error(503, {
142-
message: 'failed to fetch hackatime trust factor, please try again later'
143-
});
147+
return redirect(302, '/auth/create-hackatime-account');
148+
// return error(503, {
149+
// message: 'failed to fetch hackatime trust factor, please try again later'
150+
// });
144151
} else if (hackatimeTrust === 'red') {
145152
// Prevent login
146153
return redirect(302, 'https://fraud.land');
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script>
2+
import Head from "$lib/components/Head.svelte";
3+
</script>
4+
5+
<Head title="Auth failed" />
6+
7+
<div class="text-center mt-10">
8+
<h1 class="text-2xl">Hackatime account not found</h1>
9+
10+
<p>Make sure you have a Hackatime account associated with your Hack Club Auth or Slack account.</p>
11+
<a href="https://hackatime.hackclub.com/" class="underline mr-3">Make one?</a>
12+
<a href="/auth/idv" class="underline">Try again</a>
13+
</div>

0 commit comments

Comments
 (0)