28 lines
831 B
C#
28 lines
831 B
C#
// <copyright file="UserRoleExtensions.cs" company="alveus.dev">
|
|
// Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License.
|
|
// </copyright>
|
|
|
|
using Astral.Core.Constants;
|
|
|
|
namespace Astral.Core.Extensions;
|
|
|
|
/// <summary>
|
|
/// <see cref="UserRole"/> extensions.
|
|
/// </summary>
|
|
public static class UserRoleExtensions
|
|
{
|
|
/// <summary>
|
|
/// Get accessible roles of a user role.
|
|
/// </summary>
|
|
/// <param name="userRole">This <see cref="UserRole"/>.</param>
|
|
/// <returns>Collection of accessible <see cref="UserRole"/>.</returns>
|
|
public static UserRole[] GetAccessibleRoles(this UserRole userRole)
|
|
{
|
|
return userRole switch
|
|
{
|
|
UserRole.User => [UserRole.User],
|
|
UserRole.Admin => [UserRole.User, UserRole.Admin],
|
|
_ => []
|
|
};
|
|
}
|
|
}
|