Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/29/16 17:02:16 (8 years ago)
Author:
jlodewyc
Message:

#2582 Overhaul Login service, done

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/ResourceController.cs

    r13733 r13739  
    11using HeuristicLab.Clients.Hive.WebJobManager.Services;
    22using Microsoft.AspNet.Hosting;
     3using Microsoft.AspNet.Http;
    34using Microsoft.AspNet.Mvc;
    45using System;
     
    1213    public class ResourceController : Controller
    1314    {
    14         private HiveServiceClient client;
     15        private WebLoginService weblog;
     16        private HiveServiceLocatorWeb serviceLocator;
     17        private HiveServiceClient serviceClient;
     18        private HiveClientWeb clientWeb;
     19        private Guid userId;
     20
    1521        private IHostingEnvironment _environment;
    1622
    1723        public ResourceController(IHostingEnvironment env)
    1824        {
    19             HiveServiceLocatorWeb hiveServiceLocator = (HiveServiceLocatorWeb)HiveServiceLocatorWeb.Instance;
    20             client = hiveServiceLocator.getHiveServiceClient();
     25            weblog = WebLoginService.Instance;
     26            var u = HttpContext.Session.GetString("UserId");
     27            if (u == null || u == "" || Guid.Parse(u) == Guid.Empty)
     28            {
     29                userId = Guid.Empty;
     30                serviceLocator = new HiveServiceLocatorWeb();
     31                serviceClient = serviceLocator.getHiveServiceClient();
     32                clientWeb = new HiveClientWeb(serviceLocator, userId);
     33            }
     34            else {
     35                userId = Guid.Parse(u);
     36
     37                serviceLocator = weblog.getServiceLocator(userId);
     38                serviceClient = serviceLocator.getHiveServiceClient();
     39                clientWeb = weblog.getClientWeb(userId);
     40            }
    2141
    2242            _environment = env;
     
    2444        public IActionResult Index()
    2545        {
    26             if (((HiveServiceLocatorWeb)(HiveServiceLocatorWeb.Instance)).CheckLogin())
     46            if (serviceLocator.CheckLogin())
    2747            {
    2848
     
    3252            else
    3353            {
    34                 HiveServiceLocatorWeb.SetLoginErrorMessage();
    3554                return RedirectToAction("Index", "Home");
    3655            }
Note: See TracChangeset for help on using the changeset viewer.