mirror of
https://github.com/outline/outline.git
synced 2026-02-26 14:29:30 -06:00
fix: Cannot use Discord authentication if guild name looks like a URL, closes #7776
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import passport from "@outlinewiki/koa-passport";
|
||||
import { isURL } from "class-validator";
|
||||
import type {
|
||||
RESTGetAPICurrentUserGuildsResult,
|
||||
RESTGetAPICurrentUserResult,
|
||||
@@ -129,10 +130,19 @@ if (env.DISCORD_CLIENT_ID && env.DISCORD_CLIENT_SECRET) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Guild Name */
|
||||
teamName = guild.name;
|
||||
subdomain = slugify(guild.name);
|
||||
|
||||
/** If the guild name is a URL, use the subdomain instead – we do not allow URLs in names. */
|
||||
if (
|
||||
isURL(teamName, {
|
||||
require_host: false,
|
||||
require_protocol: false,
|
||||
})
|
||||
) {
|
||||
teamName = subdomain;
|
||||
}
|
||||
|
||||
/** Fetch the user's member object in the server for nickname and roles */
|
||||
const guildMember: RESTGetCurrentUserGuildMemberResult =
|
||||
await request(
|
||||
|
||||
Reference in New Issue
Block a user