Skip to content

Commit c81fe95

Browse files
committed
no more null exceptions in the current stage
1 parent 9971a78 commit c81fe95

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
namespace KK.AspNetCore.EasyAuthAuthentication.Models
1+
namespace KK.AspNetCore.EasyAuthAuthentication.Models
22
{
3+
using System;
34
using Newtonsoft.Json;
45

56
internal class AADClaimsModel
67
{
78
[JsonProperty("typ")]
8-
public string Typ { get; set; }
9+
public string Typ { get; set; } = string.Empty;
910

1011
[JsonProperty("val")]
11-
public string Values { get; set; }
12+
public string Values { get; set; } = string.Empty;
1213
}
1314
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ public class ProviderOptions
1616
public ProviderOptions(string providerName)
1717
{
1818
this.ProviderName = providerName;
19-
this.NameClaimType = ClaimTypes.Name;
20-
this.NameClaimType = ClaimTypes.Role;
2119
}
2220

2321
/// <summary>
@@ -29,8 +27,7 @@ public ProviderOptions(string providerName)
2927
public ProviderOptions(string providerName, string nameClaimType)
3028
{
3129
this.ProviderName = providerName;
32-
this.NameClaimType = nameClaimType;
33-
this.NameClaimType = ClaimTypes.Role;
30+
this.NameClaimType = nameClaimType;
3431
}
3532

3633
/// <summary>
@@ -51,13 +48,13 @@ public ProviderOptions(string providerName, string nameClaimType, string roleNam
5148
/// The <c>ClaimType</c> for the Idendity User.
5249
/// </summary>
5350
/// <value>The Claim Type to use for the User. Default is <c>ClaimType</c> of the auth provider.</value>
54-
public string NameClaimType { get; set; }
51+
public string NameClaimType { get; set; } = ClaimTypes.Name;
5552

5653
/// <summary>
5754
/// The <c>ClaimType</c> for the Idendity Role.
5855
/// </summary>
5956
/// <value>The Claim Type to use for the Roles. Default is <c>ClaimType</c> of the auth provider.</value>
60-
public string RoleClaimType { get; set; }
57+
public string RoleClaimType { get; set; } = ClaimTypes.Role;
6158

6259
/// <summary>
6360
/// The provider name for this options object.

src/KK.AspNetCore.EasyAuthAuthentication/Services/EasyAuthWithAuthMeService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private AuthenticationTicket BuildIdentityFromEasyAuthMeJson(JObject payload)
104104

105105
private async Task<JArray> GetAuthMe(HttpClientHandler handler, HttpRequestMessage httpRequest)
106106
{
107-
JArray payload = null;
107+
JArray? payload = null;
108108
using (var client = new HttpClient(handler))
109109
{
110110
var response = await client.SendAsync(httpRequest);

0 commit comments

Comments
 (0)