public AccountController(TimetrackerContext dbContext) { _dbContext = dbContext; _jsonOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; }
public RoleController(TimetrackerContext context) { _context = context; _jsonOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; }
public ProjectController(TimetrackerContext dbcontext, IHubContext <TrackingHub> hub) { _dbContext = dbcontext; _jsonOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; _hub = new Lazy <IHubContext <TrackingHub> >(hub); }
public static async Task GenerateToken(string id, Token user, TimetrackerContext context, bool isNew = false) { var claims = new List <Claim> { new Claim(ClaimsIdentity.DefaultNameClaimType, id) }; var claimsIdentity = new ClaimsIdentity(claims, "Token", ClaimsIdentity.DefaultNameClaimType, ClaimsIdentity.DefaultRoleClaimType); var now = DateTime.UtcNow; var expiredIn = now.Add(tokenDurability); var jwt = new JwtSecurityToken( issuer: TimetrackerAuthorizationOptions.ISSUER, audience: TimetrackerAuthorizationOptions.AUDIENCE, notBefore: now, claims: claimsIdentity.Claims, expires: expiredIn, signingCredentials: new SigningCredentials( TimetrackerAuthorizationOptions.GetSymmetricSecurityKey(), SecurityAlgorithms.HmacSha256) ); var access_token = new JwtSecurityTokenHandler().WriteToken(jwt); var refresh_token = Guid.NewGuid().ToString().Replace("-", ""); user.AccessToken = access_token; user.RefreshToken = refresh_token; user.TokenExpiredDate = expiredIn; if (isNew) { await context.AddAsync(user) .ConfigureAwait(false); } await context.SaveChangesAsync(true) .ConfigureAwait(false); }
public TimeTrackerService() { _context = new TimetrackerContext(); }
public TaskController(TimetrackerContext context, IHubContext <TrackingHub> hub) { _context = context; _hub = new Lazy <IHubContext <TrackingHub> >(hub); }
public WorktrackController(TimetrackerContext context) { _context = context; }
public TrackingHub(TimetrackerContext dbContext) { _dbContext = dbContext; }