Skip to content

Commit

Permalink
Fixed potential null reference bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarincev committed Feb 15, 2018
1 parent cf19294 commit bbe6712
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,13 @@ public static async Task WithCurrentUserAsync(this IWorkContextBuilder builder)
if (identity.IsAuthenticated)
{
user = await signInManager.UserManager.FindByNameAsync(identity.Name);
//User has been removed from storage need to do sign out
if (user == null)
{
await signInManager.SignOutAsync();
}

//Current store is not allowed for signed in user - do sign out
if (!user.AllowedStores.Contains(builder.WorkContext.CurrentStore.Id))
//User has been removed from storage or current store is not allowed for signed in user
//need to do sign out
if (user == null || !user.AllowedStores.Contains(builder.WorkContext.CurrentStore.Id))
{
await signInManager.SignOutAsync();
user = null;
}
}
}

if (user == null || user.IsTransient())
Expand Down

0 comments on commit bbe6712

Please sign in to comment.