public List <Claim> GetClaims(Guid userId, string secretKey) { var jtiGuid = _newGuidProvider.Get(); return(new List <Claim> { new Claim(JwtRegisteredClaimNames.Jti, jtiGuid.ToString()), new Claim(ClaimTypes.NameIdentifier, userId.ToString()), new Claim(ProjectClaims.OtpTokenSecretKeyClaimName, secretKey) } .ToList()); }
public List <Claim> GetClaims(Guid userId, bool hasLongTimeToLive, IList <string> roles) { var jtiGuid = _newGuidProvider.Get(); return(new List <Claim> { new Claim(JwtRegisteredClaimNames.Jti, jtiGuid.ToString()), new Claim(ClaimTypes.NameIdentifier, userId.ToString()), new Claim(ProjectClaims.JwtTokenHasLongTimeToLiveClaimName, hasLongTimeToLive.ToString()) } .Concat(roles.Select(role => new Claim(ClaimTypes.Role, role))) .ToList()); }
public Employee Prepare(Employee employee, Company company) { employee.CompanyId = company.Id; employee.TenantId = company.TenantId; employee.SecurityUser.TenantId = company.TenantId; employee.SecurityUser.User.ConcurrencyStamp = _newGuidProvider.Get().ToString(); employee.SecurityUser.User.Roles = new List <UserRole> { new UserRole { RoleId = UserRoles.Employee.RoleId } }; return(employee); }
public User Convert(CompanyRegisterRequest request) { var company = new Company { Name = request.CompanyName, Phone = request.CompanyPhone, Address = request.Address, City = request.City, Zip = request.Zip, INN = request.Inn, }; var tenant = new Tenant { IsActive = true, Name = request.CompanyName, Company = company, }; return(new User { UserName = request.Email, Email = request.Email, SecurityUser = new SecurityUser { Tenant = tenant, IsActive = true, IsInvited = true, IsInvitationAccepted = true, Employee = new Employee { Company = company, FirstName = request.FirstName, LastName = request.LastName, PatronymicName = request.PatronymicName, Gender = request.Gender, DateOfBirth = request.DateOfBirth, Tenant = tenant, } }, ConcurrencyStamp = _newGuidProvider.Get().ToString() }); }