Improve user flow
This commit is contained in:
parent
22971f460d
commit
2f0b7da130
2 changed files with 54 additions and 3 deletions
|
@ -39,19 +39,39 @@ export async function GET(request: NextRequest) {
|
||||||
// Test for user existence
|
// Test for user existence
|
||||||
let tUserExists = await mauth.verifyUser(tUserToken.token_type + " " + tUserToken.access_token);
|
let tUserExists = await mauth.verifyUser(tUserToken.token_type + " " + tUserToken.access_token);
|
||||||
|
|
||||||
console.log(tUserExists,);
|
console.log(tUserExists);
|
||||||
|
|
||||||
if (tUserExists == null) return new Response('', {
|
if (tUserExists == null) return new Response('', {
|
||||||
status: 400
|
status: 400
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check if user is "dangerous"
|
||||||
|
|
||||||
|
const t1ListRequest = await fetch("https://seirdy.one/pb/tier1.csv");
|
||||||
|
|
||||||
|
const t1List = await t1ListRequest.text();
|
||||||
|
|
||||||
|
if (t1List == null) return new Response('', {
|
||||||
|
status: 500
|
||||||
|
});
|
||||||
|
|
||||||
|
// Split lists
|
||||||
|
|
||||||
|
const JSONt1List = t1List.split("\n").slice(2).map(x => x.split(",")[0]);
|
||||||
|
|
||||||
|
// Impersonation check
|
||||||
|
|
||||||
|
if (!tUserExists.url.includes(instance) && !tUserExists.url.includes(tUserExists.acct)) return new Response(`URL is invalid`, {
|
||||||
|
status: 401
|
||||||
|
});
|
||||||
|
|
||||||
let currentUser = {
|
let currentUser = {
|
||||||
id: nanoid(21),
|
id: nanoid(21),
|
||||||
instance,
|
instance,
|
||||||
username: tUserExists.acct,
|
username: tUserExists.acct,
|
||||||
admin: false,
|
admin: false,
|
||||||
url: tUserExists.url,
|
url: tUserExists.url,
|
||||||
banned: false,
|
banned: JSONt1List.includes(instance), // If user's domain is on tier1, start user banned
|
||||||
joined: Date.now()
|
joined: Date.now()
|
||||||
} as UserTable;
|
} as UserTable;
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,37 @@ export async function GET(request: NextRequest) {
|
||||||
});
|
});
|
||||||
const mauth = new MastoAuth(instance);
|
const mauth = new MastoAuth(instance);
|
||||||
|
|
||||||
|
// Check if instance is fediblocked
|
||||||
|
|
||||||
|
const fnListRequest = await fetch("https://seirdy.one/pb/FediNuke.txt");
|
||||||
|
|
||||||
|
const fnList = await fnListRequest.text();
|
||||||
|
|
||||||
|
if (fnList == null) return new Response('', {
|
||||||
|
status: 500
|
||||||
|
});
|
||||||
|
|
||||||
|
const ssListRequest = await fetch("https://seirdy.one/pb/spammy-subdomains.txt");
|
||||||
|
|
||||||
|
const ssList = await ssListRequest.text();
|
||||||
|
|
||||||
|
if (ssList == null) return new Response('', {
|
||||||
|
status: 500
|
||||||
|
});
|
||||||
|
|
||||||
|
// Split lists
|
||||||
|
|
||||||
|
const JSONFnList = fnList.split("\n");
|
||||||
|
const JSONSsList = ssList.split("\n");
|
||||||
|
|
||||||
|
if (JSONSsList.includes(instance)) return new Response('https://seirdy.one/pb/spammy-subdomains.txt', {
|
||||||
|
status: 403
|
||||||
|
});
|
||||||
|
|
||||||
|
if (JSONFnList.includes(instance)) return new Response('https://seirdy.one/pb/FediNuke.txt', {
|
||||||
|
status: 403
|
||||||
|
});
|
||||||
|
|
||||||
// Check if instance app exists
|
// Check if instance app exists
|
||||||
let existingInstanceApp = await db
|
let existingInstanceApp = await db
|
||||||
.selectFrom('apps')
|
.selectFrom('apps')
|
||||||
|
|
Loading…
Reference in a new issue