Enhanced Discord Support (#7005)
* Add Discord Provider Prototype * Add Discord Logo * Add Plugin to Plugin Manager * fixed discord auth support and added icon * add csv role verification * grab discord server icon and test server id and roles * subdomain derived from server name * use discord server specific nickname if available * Cleanup and comment * move discord api types to dev deps * cleanup of server vs default params * remove commented out lines * revert envv.development * revert in vscode * update yarn lock * add gif support for discord server icon * add comment with docs link * add env section for discord * fix errors and clarify env * add new cannot use without * fix suggestions
This commit is contained in:
committed by
GitHub
parent
379d2cb788
commit
a9f1086422
@@ -14,9 +14,9 @@ import { User } from "@server/models";
|
||||
import { AuthenticationResult } from "@server/types";
|
||||
import {
|
||||
StateStore,
|
||||
request,
|
||||
getTeamFromContext,
|
||||
getClientFromContext,
|
||||
request,
|
||||
} from "@server/utils/passport";
|
||||
import config from "../../plugin.json";
|
||||
import env from "../env";
|
||||
@@ -24,15 +24,6 @@ import env from "../env";
|
||||
const router = new Router();
|
||||
const scopes = env.OIDC_SCOPES.split(" ");
|
||||
|
||||
Strategy.prototype.userProfile = async function (accessToken, done) {
|
||||
try {
|
||||
const response = await request(env.OIDC_USERINFO_URI ?? "", accessToken);
|
||||
return done(null, response);
|
||||
} catch (err) {
|
||||
return done(err);
|
||||
}
|
||||
};
|
||||
|
||||
const authorizationParams = Strategy.prototype.authorizationParams;
|
||||
Strategy.prototype.authorizationParams = function (options) {
|
||||
return {
|
||||
@@ -81,7 +72,7 @@ if (
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
params: { expires_in: number },
|
||||
profile: Record<string, string>,
|
||||
_profile: unknown,
|
||||
done: (
|
||||
err: Error | null,
|
||||
user: User | null,
|
||||
@@ -89,6 +80,11 @@ if (
|
||||
) => void
|
||||
) {
|
||||
try {
|
||||
const profile = await request(
|
||||
env.OIDC_USERINFO_URI ?? "",
|
||||
accessToken
|
||||
);
|
||||
|
||||
if (!profile.email) {
|
||||
throw AuthenticationError(
|
||||
`An email field was not returned in the profile parameter, but is required.`
|
||||
|
||||
Reference in New Issue
Block a user