Skip to content

Commit eee33b1

Browse files
committed
Fix Null ref in User detailts page
1 parent cd20c50 commit eee33b1

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/JoinRpg.DataModel/Users/User.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class User
4242

4343
public virtual AllrpgUserDetails Allrpg { get; set; }
4444
[CanBeNull]
45-
public virtual UserExtra Extra { get; set; }
45+
public virtual UserExtra? Extra { get; set; }
4646

4747
public virtual HashSet<UserSubscription> Subscriptions { get; set; }
4848

src/JoinRpg.Portal/Controllers/UserProfile/UserController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public async Task<ActionResult> Details(int userId)
2020
{
2121
var user = await UserRepository.GetById(userId);
2222

23-
var currentUser = User.Identity.IsAuthenticated ? await UserRepository.GetById(CurrentUserAccessor.UserId) : null;
23+
var currentUser = User.Identity?.IsAuthenticated == true ? await UserRepository.GetById(CurrentUserAccessor.UserId) : null;
2424

2525
var accessReason = (AccessReason)user.GetProfileAccess(currentUser);
2626
var userProfileViewModel = new UserProfileViewModel()

src/JoinRpg.WebPortal.Models/JoinRpg.WebPortal.Models.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net5</TargetFramework>
55
<RootNamespace>JoinRpg.Web.Models</RootNamespace>
66
<NoWarn>${NoWarn};1591</NoWarn>
7-
<Nullable>annotations</Nullable>
7+
<Nullable>enable</Nullable>
88
</PropertyGroup>
99

1010
<ItemGroup>

src/JoinRpg.WebPortal.Models/UserProfile/UserProfileViewModel.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public IEnumerable<ProjectLinkViewModel> ProjectsToAdd
2525
=> CanGrantAccessProjects.Where(acl => ThisUserProjects.All(acl1 => acl1.ProjectId != acl.ProjectId));
2626

2727
[ReadOnly(true)]
28-
public ClaimListViewModel Claims { get; set; }
28+
public ClaimListViewModel? Claims { get; set; }
2929

3030
public UserProfileDetailsViewModel Details { get; set; }
3131

@@ -47,21 +47,21 @@ public class UserProfileDetailsViewModel
4747
[Display(Name = "Номер телефона"), DataType(DataType.PhoneNumber), UIHint("PhoneNumber")]
4848
public string PhoneNumber { get; }
4949
[Display(Name = "Skype"), UIHint("Skype")]
50-
public string Skype { get; }
50+
public string? Skype { get; }
5151
[Display(Name = "Telegram"), UIHint("Telegram")]
52-
public string Telegram { get; }
52+
public string? Telegram { get; }
5353
[Display(Name = "ЖЖ"), UIHint("Livejournal")]
54-
public string Livejournal { get; }
54+
public string? Livejournal { get; }
5555
[Display(Name = "VK"), UIHint("Vkontakte")]
56-
public string Vk { get; }
56+
public string? Vk { get; }
5757
[UIHint("Email")]
5858
public string Email { get; }
5959
[DisplayName("ФИО")]
6060
public string FullName { get; }
6161

6262
public int? AllrpgId { get; }
6363

64-
public AvatarIdentification Avatar { get; }
64+
public AvatarIdentification? Avatar { get; }
6565
[Editable(false)]
6666
public UserLinkViewModel User { get; }
6767

@@ -95,7 +95,7 @@ public UserProfileDetailsViewModel(User user, AccessReason reason)
9595
IsVerifiedUser = user.VerifiedProfileFlag;
9696
IsAdmin = user.Auth.IsAdmin;
9797
}
98-
if (HasAccess || user.Extra.SocialNetworksAccess == ContactsAccessType.Public)
98+
if (HasAccess || user.Extra?.SocialNetworksAccess == ContactsAccessType.Public)
9999
{
100100
Vk = user.Extra?.Vk;
101101
AllrpgId = user.Allrpg?.Sid;

0 commit comments

Comments
 (0)