Skip to content

Commit 510afa4

Browse files
authored
Fixed null error
When you are on localhost with another site that you are logged into, line `39` picks up the cookie, but it is not valid for this site. This makes the `unprotected` variable null and throws an error. This code fix checks if `unprotected` is null first and handles it accordingly.
1 parent 1345a60 commit 510afa4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Our.Umbraco.TagHelpers/Services/BackofficeUserAccessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public ClaimsIdentity BackofficeUser
4242
return new ClaimsIdentity();
4343

4444
AuthenticationTicket? unprotected = cookieOptions.TicketDataFormat.Unprotect(backOfficeCookie!);
45-
ClaimsIdentity backOfficeIdentity = unprotected!.Principal.GetUmbracoIdentity();
45+
ClaimsIdentity? backOfficeIdentity = unprotected?.Principal.GetUmbracoIdentity();
4646

47-
return backOfficeIdentity;
47+
return backOfficeIdentity ?? new ClaimsIdentity();
4848
}
4949
}
5050
}
51-
}
51+
}

0 commit comments

Comments
 (0)