public string SignIn(string email, string password) { bool validate = UserValidate(email, password); if (!validate) { throw new UnauthorizedAccessException("Email or password is incorrect"); } User user = UserFindByEmail(email); UserGroup userGroup = _userGroupRepository.Find(user.UserGroupId); var roles = _userGroupService.GetAuthorizedRoles(userGroup); string userGroupName = ""; if (userGroup != null) { userGroupName = userGroup.Name; } var token = new JwtTokenBuilder() .AddSecurityKey(JwtSecurityKey.Create("fiver-secret-key")) .AddSubject(email) .AddIssuer("fiver.Security.Bearer") .AddAudience("fiver.Security.Bearer") .AddClaim("UserId", user.Id.ToString()) .AddClaim("User", user.ConvertJsonFromObject()) .AddClaim("Roles", roles.ConvertJsonFromObject()) .AddClaim("UserGroup", userGroupName) .AddExpiry(10) .Build(); return(token.Value); }