Beispiel #1
0
 public AuthenticationController(
     MoviemindAPIService moviemindAPIService,
     IStateManagementService stateManagementService)
 {
     _moviemindAPIService    = moviemindAPIService;
     _stateManagementService = stateManagementService;
 }
 public RegistrationController(
     MoviemindAPIService moviemindAPIService,
     IStateManagementService stateManagementService,
     IStringLocalizer <RegistrationController> localizer)
 {
     _moviemindAPIService    = moviemindAPIService;
     _stateManagementService = stateManagementService;
     _localizer = localizer;
 }
 public AssociateToolService(IStateManagementService stateManagementService,
                             IToolTypeService toolTypeService,
                             IToolService toolService,
                             IThingGroupService thingGroupService,
                             IConfiguration configuration)
 {
     _toolTypeService        = toolTypeService;
     _toolService            = toolService;
     _stateManagementService = stateManagementService;
     _thingGroupService      = thingGroupService;
     _configuration          = configuration;
 }
 public AssociateProductionOrderService(IProductionOrderTypeService productionOrderTypeService,
                                        IProductionOrderService productionOrderService,
                                        IStateManagementService stateManagementService,
                                        IThingGroupService thingGroupService,
                                        IConfiguration configuration)
 {
     _configuration = configuration;
     _productionOrderTypeService = productionOrderTypeService;
     _productionOrderService     = productionOrderService;
     _stateManagementService     = stateManagementService;
     _thingGroupService          = thingGroupService;
 }
Beispiel #5
0
 public StateManagementController(IStateManagementService stateManagementService)
 {
     _stateManagementService = stateManagementService;
 }
Beispiel #6
0
 public TokenValidationService(IHttpContextAccessor httpContextAccessor, MoviemindAPIService moviemindAPIService, IStateManagementService stateManagementService)
 {
     _httpContextAccessor    = httpContextAccessor;
     _moviemindAPIService    = moviemindAPIService;
     _stateManagementService = stateManagementService;
 }
        public async Task InvokeAsync(HttpContext context, MoviemindAPIService movieMindAPIService, IStateManagementService stateManagementService)
        {
            // Token validation is not required for authentication and registration
            if (!context.Request.Path.Value.Contains("Registration") && !context.Request.Path.Value.Contains("Authentication"))
            {
                // Check if JWT token exists in session, if not redirect to login page
                if (string.IsNullOrEmpty(context.Session.GetString("_JwtToken")))
                {
                    context.Response.Redirect("/Authentication");
                    return;
                }
                else
                {
                    var expiresOn = Convert.ToDateTime(context.Session.GetString("_JwtExpiresOn"));
                    // JWT exist in session, check if expired
                    if (expiresOn < DateTime.UtcNow)
                    {
                        // Unnecesary because check is done at back-end but this client-side check saves an API call
                        // Check if refresh token is expired
                        // If expired the user needs to authenticate with credentials
                        var rtexpireson = Convert.ToDateTime(context.Session.GetString("_RtExpiresOn"));
                        if (rtexpireson < DateTime.UtcNow)
                        {
                            context.Session.SetString("SessionExpired", "Your session is expired");
                            context.Response.Redirect("/Authentication");
                            return;

                            //throw new TokenException("Uw sessie is verlopen", "TokenValidationMiddleware", "InvokeAsync", "401");
                        }
                        else
                        {
                            // If not expired a request to /api/Users/refresh-token is required to get a new set of tokens
                            PostAuthenticateResponseModel postAuthenticateResponseModel = await movieMindAPIService.RefreshToken();

                            // Update the session data with the new set of tokens
                            stateManagementService.SetState(postAuthenticateResponseModel);
                        }
                    }
                }
            }

            // Call the next delegate/middleware in the pipeline
            await _next(context);
        }
 public async Task InvokeAsync(HttpContext context, IStateManagementService stateManagementService)
 {
     // Call the next delegate/middleware in the pipeline
     await _next(context);
 }
 public StateConfigurationController(IStateManagementService stateManagementService)
 {
     _stateManagementService = stateManagementService;
 }