Skip to content

Auth · Modules

3 modules · 11 exports · 1 repository · 4 e2e tests · 8 routes

Who imports who · hover a node
Depends onAuth modulesUsed byDiscordAvatar.server2 …DiscordRefresh.serverDiscordStrategy.serverOther3 files

DiscordAvatar

serverapp/features/auth/core/DiscordAvatar.server.ts

No overview comment at the top of the file.

Imports
no other modules
Used by
1 module2 other

Functions & values

function

syncForUser

:18

Brings the user's synced avatar up to date with their Discord avatar newHash: copies the new avatar to S3 as an image and deletes the previous one. Also copies an unchanged avatar that was never stored (users skipped by the avatar migration). Never throws, a failed copy keeps the previous avatar.

export async function syncForUser({
	user,
	discordId,
	newHash,
}: {
	user: {
		id: number;
		discordAvatar: string | null;
		syncedAvatarImgId: number | null;
	};
	discordId: string;
	newHash: string | null;
})
Unit tests (6)
function

fileNameOf

:99

File name a Discord avatar is stored under, its small copy is next to it.

export function fileNameOf({ userId, hash }: { userId: number; hash: string })

DiscordRefresh

serverapp/features/auth/core/DiscordRefresh.server.ts

No overview comment at the top of the file.

Imports
no other modules
Used by
1 other

Types

interface

FlaggedRefresh

no JSDoc:18
export interface FlaggedRefresh {
	userId: number;
	returnTo: string | null;
}

Functions & values

function

flagCookieHeader

:29

Set-Cookie value marking the next OAuth callback as a profile refresh of the given user instead of a log in.

export function flagCookieHeader(refresh: FlaggedRefresh)
function

clearFlagCookieHeader

no JSDoc:33
export function clearFlagCookieHeader()
function

flaggedRefresh

:38

The profile refresh in progress, or null if the OAuth flow is a regular log in.

export async function flaggedRefresh(
	request: Request,
): Promise<FlaggedRefresh | null>
function

isOnCooldown

:51

Whether the user refreshed recently. Each refresh costs Discord API calls shared with log in's rate limit.

export function isOnCooldown(userId: number)
function

startCooldown

no JSDoc:57
export function startCooldown(userId: number)

DiscordStrategy

serverapp/features/auth/core/DiscordStrategy.server.ts

No overview comment at the top of the file.

Imports
DiscordAvatar.server
Used by
2 other

Types

type

DiscordProfile

no JSDoc:111
export type DiscordProfile = {
	user: v.InferOutput<typeof partialDiscordUserSchema>;
	connections: v.InferOutput<typeof partialDiscordConnectionsSchema>;
};

Functions & values

function

DiscordStrategy

no JSDoc:38
export const DiscordStrategy = () =>
function

upsertUser

:135

Creates or updates the user (name, avatar, connections) from their Discord profile and returns their id. Unverified Discord accounts can't register.

export async function upsertUser({ user, connections }: DiscordProfile)