Skip to content

Commit 9971a78

Browse files
committed
remove possible nulls in provider options
1 parent 81a5a85 commit 9971a78

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/KK.AspNetCore.EasyAuthAuthentication/Models/ProviderOptions.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace KK.AspNetCore.EasyAuthAuthentication.Models
22
{
33
using System;
4+
using System.Security.Claims;
45

56
/// <summary>
67
/// All options you can set per provider.
@@ -15,6 +16,35 @@ public class ProviderOptions
1516
public ProviderOptions(string providerName)
1617
{
1718
this.ProviderName = providerName;
19+
this.NameClaimType = ClaimTypes.Name;
20+
this.NameClaimType = ClaimTypes.Role;
21+
}
22+
23+
/// <summary>
24+
/// Initializes a new instance of the <see cref="ProviderOptions"/> class.
25+
/// </summary>
26+
/// <param name="providerName">The name of the provider.</param>
27+
/// <param name="nameClaimType">The name of the field in the provider data, that contains the name of the user.</param>
28+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0021:Use expression body for constructors", Justification = "This syntax is better for the human eyes.")]
29+
public ProviderOptions(string providerName, string nameClaimType)
30+
{
31+
this.ProviderName = providerName;
32+
this.NameClaimType = nameClaimType;
33+
this.NameClaimType = ClaimTypes.Role;
34+
}
35+
36+
/// <summary>
37+
/// Initializes a new instance of the <see cref="ProviderOptions"/> class.
38+
/// </summary>
39+
/// <param name="providerName">The name of the provider.</param>
40+
/// <param name="nameClaimType">The name of the field in the provider data, that contains the name of the user.</param>
41+
/// <param name="roleNameClaimType">The name of the field in the provider data, that contains all roles of the user.</param>
42+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0021:Use expression body for constructors", Justification = "This syntax is better for the human eyes.")]
43+
public ProviderOptions(string providerName, string nameClaimType, string roleNameClaimType)
44+
{
45+
this.ProviderName = providerName;
46+
this.NameClaimType = nameClaimType;
47+
this.NameClaimType = roleNameClaimType;
1848
}
1949

2050
/// <summary>

0 commit comments

Comments
 (0)