Added endpoint for registering a user locally after successful logon from Auth0
This commit is contained in:
14
YABA.Common/Attributes/ClaimNameAttribute.cs
Normal file
14
YABA.Common/Attributes/ClaimNameAttribute.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace YABA.Common.Attributes
|
||||
{
|
||||
public class ClaimNameAttribute : Attribute
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
|
||||
public ClaimNameAttribute(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
YABA.Common/Extensions/EnumExtensions.cs
Normal file
29
YABA.Common/Extensions/EnumExtensions.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using YABA.Common.Attributes;
|
||||
using YABA.Common.Lookups;
|
||||
|
||||
namespace YABA.Common.Extensions
|
||||
{
|
||||
public static class EnumExtensions
|
||||
{
|
||||
public static TAttribute GetAttribute<TAttribute>(this Enum value) where TAttribute : Attribute
|
||||
{
|
||||
var enumType = value.GetType();
|
||||
var name = Enum.GetName(enumType, value);
|
||||
return enumType.GetField(name).GetCustomAttributes(false).OfType<TAttribute>().SingleOrDefault();
|
||||
}
|
||||
|
||||
public static string GetDisplayName(this Enum enumValue)
|
||||
{
|
||||
return enumValue.GetAttribute<DisplayAttribute>().Name;
|
||||
}
|
||||
|
||||
public static string GetClaimName(this ClaimsLookup claimLookup)
|
||||
{
|
||||
return claimLookup.GetAttribute<ClaimNameAttribute>().Name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
22
YABA.Common/Lookups/ClaimsLookup.cs
Normal file
22
YABA.Common/Lookups/ClaimsLookup.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using YABA.Common.Attributes;
|
||||
|
||||
namespace YABA.Common.Lookups
|
||||
{
|
||||
public enum ClaimsLookup
|
||||
{
|
||||
[ClaimNameAttribute("https://dev.iwanaga.moe/api/auth_provider_id")]
|
||||
AuthProviderId = 1,
|
||||
|
||||
[ClaimNameAttribute("https://dev.iwanaga.moe/api/email_address")]
|
||||
UserEmail = 2,
|
||||
|
||||
[ClaimNameAttribute("https://dev.iwanaga.moe/api/email_verified")]
|
||||
IsEmailConfirmed = 3,
|
||||
|
||||
[ClaimNameAttribute("https://dev.iwanaga.moe/api/username")]
|
||||
Username = 4,
|
||||
|
||||
[ClaimNameAttribute("https://dev.iwanaga.moe/api/id")]
|
||||
UserId = 5
|
||||
}
|
||||
}
|
||||
12
YABA.Common/YABA.Common.csproj
Normal file
12
YABA.Common/YABA.Common.csproj
Normal file
@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user