Add allow guests to the server-info struct

This commit is contained in:
Zoe Roux 2024-03-04 23:44:26 +01:00
parent c48ee975c6
commit f4464578c0
3 changed files with 14 additions and 1 deletions

View File

@ -26,6 +26,11 @@ public class ServerInfo
/// The list of oidc providers configured for this instance of kyoo. /// The list of oidc providers configured for this instance of kyoo.
/// </summary> /// </summary>
public Dictionary<string, OidcInfo> Oidc { get; set; } public Dictionary<string, OidcInfo> Oidc { get; set; }
/// <summary>
/// True if guest accounts are allowed on this instance.
/// </summary>
public bool AllowGuests { get; set; }
} }
public class OidcInfo public class OidcInfo

View File

@ -38,6 +38,7 @@ public class InfoApi(PermissionOption options) : ControllerBase
return Ok( return Ok(
new ServerInfo() new ServerInfo()
{ {
AllowGuests = options.Default.Any(),
Oidc = options Oidc = options
.OIDC.Select(x => new KeyValuePair<string, OidcInfo>( .OIDC.Select(x => new KeyValuePair<string, OidcInfo>(
x.Key, x.Key,

View File

@ -33,6 +33,10 @@ export const OidcInfoP = z.object({
}); });
export const ServerInfoP = z.object({ export const ServerInfoP = z.object({
/*
* True if guest accounts are allowed on this instance.
*/
allowGuests: z.boolean(),
/* /*
* The list of oidc providers configured for this instance of kyoo. * The list of oidc providers configured for this instance of kyoo.
*/ */
@ -42,7 +46,10 @@ export const ServerInfoP = z.object({
Object.fromEntries( Object.fromEntries(
Object.entries(x).map(([provider, info]) => [ Object.entries(x).map(([provider, info]) => [
provider, provider,
{ ...info, link: imageFn(`/auth/login/${provider}?redirectUrl=${baseAppUrl()}/login/callback`) }, {
...info,
link: imageFn(`/auth/login/${provider}?redirectUrl=${baseAppUrl()}/login/callback`),
},
]), ]),
), ),
), ),