Skip to content

Commit

Permalink
Add addCookieWithConfigureOptions to CookieExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ycanardeau committed May 26, 2024
1 parent 9e9eaff commit fb072aa
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions packages/authentication.cookies/src/CookieExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,53 @@ function addCookieWithAuthenticationScheme(
);
}

// https://source.dot.net/#Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs,af9790eb5f8abc9f,references
export function addCookie(
// https://source.dot.net/#Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs,0b8b178019b6d4af,references
function addCookieWithConfigureOptions(
builder: AuthenticationBuilder,
configureOptions: (options: CookieAuthenticationOptions) => void,
): AuthenticationBuilder {
return addCookieWithAuthenticationScheme(
return addCookieWithAuthenticationSchemeAndConfigureOptions(
builder,
CookieAuthenticationDefaults.authenticationScheme,
configureOptions,
);
}

// https://source.dot.net/#Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs,af9790eb5f8abc9f,references
export function addCookie(
builder: AuthenticationBuilder,
): AuthenticationBuilder;
export function addCookie(
builder: AuthenticationBuilder,
authenticationScheme: string,
configureOptions: (options: CookieAuthenticationOptions) => void,
): AuthenticationBuilder;
export function addCookie(
builder: AuthenticationBuilder,
authenticationScheme?: string,
configureOptions?: (options: CookieAuthenticationOptions) => void,
): AuthenticationBuilder {
if (authenticationScheme === undefined) {
if (configureOptions === undefined) {
return addCookieWithAuthenticationScheme(
builder,
CookieAuthenticationDefaults.authenticationScheme,
);
} else {
return addCookieWithConfigureOptions(builder, configureOptions);
}
} else {
if (configureOptions === undefined) {
return addCookieWithAuthenticationScheme(
builder,
authenticationScheme,
);
} else {
return addCookieWithAuthenticationSchemeAndConfigureOptions(
builder,
authenticationScheme,
configureOptions,
);
}
}
}

0 comments on commit fb072aa

Please sign in to comment.