Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/ResourceController.cs @ 13739

Last change on this file since 13739 was 13739, checked in by jlodewyc, 8 years ago

#2582 Overhaul Login service, done

File size: 1.8 KB
Line 
1using HeuristicLab.Clients.Hive.WebJobManager.Services;
2using Microsoft.AspNet.Hosting;
3using Microsoft.AspNet.Http;
4using Microsoft.AspNet.Mvc;
5using System;
6using System.Collections.Generic;
7using System.Linq;
8using System.ServiceModel.Security;
9using System.Threading.Tasks;
10
11namespace HeuristicLab.Clients.Hive.WebJobManager.Controllers
12{
13    public class ResourceController : Controller
14    {
15        private WebLoginService weblog;
16        private HiveServiceLocatorWeb serviceLocator;
17        private HiveServiceClient serviceClient;
18        private HiveClientWeb clientWeb;
19        private Guid userId;
20
21        private IHostingEnvironment _environment;
22
23        public ResourceController(IHostingEnvironment env)
24        {
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            }
41
42            _environment = env;
43        }
44        public IActionResult Index()
45        {
46            if (serviceLocator.CheckLogin())
47            {
48
49                ViewBag.Title = "Resources";
50                return View("Index");
51            }
52            else
53            {
54                return RedirectToAction("Index", "Home");
55            }
56        }
57    }
58}
Note: See TracBrowser for help on using the repository browser.