blob: 44f3ea445393dd6356ca38c58b371e40babb186d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Authentication;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using Tango.BL;
using Tango.MachineService.Models;
using Tango.Web.ActiveDirectory;
using Tango.Web.Helpers;
namespace Tango.MachineService.Controllers
{
public class AccountController : Controller
{
private ActiveDirectoryManager _ad_manager;
public AccountController()
{
_ad_manager = new ActiveDirectoryManager();
}
public ActionResult Login()
{
if (HttpContext.User.Identity.IsAuthenticated)
{
return RedirectToAction("Index", "Downloads", null);
}
return View();
}
[HttpPost]
public ActionResult Login(AccountLogin request)
{
var authResult = _ad_manager.ValidateUserCredentials(request.Email, request.Password);
//if (!_ad_manager.CanUserAccessCurrentEnvironment(request.Email))
//{
// throw new AuthenticationException($"You do not have permissions to access the {MachineServiceConfig.DEPLOYMENT_SLOT.ToDescription()} environment.");
//}
FormsAuthentication.SetAuthCookie(request.Email, true);
return new HttpStatusCodeResult(HttpStatusCode.OK);
}
[Authorize]
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return Login();
}
}
}
|