4

Don't Repeat Yourself. That is a common theme in Programming, I found a place where you can DRY out your code a little bit by extracting a return statement from an if block in your GetEmailAsync, it actually makes your code shorter and removes the need for the else statement. Your Code: public Task<string> GetEmailAsync(ApplicationUser user) { ...


2

First, avoid .Result within async methods [HttpPost] [ValidateAntiForgeryToken] public async Task<ActionResult> Edit(User model) { //... var userList = this.unitOfWork.UserRepository.GetAll().Result; //... } as those blocking calls can lead to deadlocks. Make the function async all the way through [HttpPost] [ValidateAntiForgeryToken] ...


2

Sometimes breaking things up into smaller manageable chunks makes them easier to swallow Break the responsibilities up into more focused concerns. public static class PrincipalExtension { /// <summary> /// Retrieves the Firm Id claim if it exists /// </summary> public static long? GetFirmId(this IPrincipal principal) { ...


2

Yes. You are close, man! You have to make relashionships between pairs of controller+action to some user actions. For example: Security Staff can only view Personal Info: - View Personal Then your HHRR Manager can: - View Personal - Add Personal - Edit Personal And finally HHRR Director he can do more actions like: View Personal Add Personal Edit ...


1

It is fine to refresh the token on every app start. It will also prevent potential hijacked tokens to be usefull for a longer time, when the token is refreshed everytime the user starts the app and the old token becomes invalid.


1

I don't think it can be done at design time given generic constraints. Second best option would be at runtime. There are 2 runtime constraints: TNullableKey must be null-assignable (reference type or nullable type) The underluying type of TNullableKey must be of type TKey code public class FrameworkUser<TKey, TNullableKey> : IdentityUser<TKey> ...


Only top voted, non community-wiki answers of a minimum length are eligible