/// <summary> /// Initializes the models /// </summary> /// <author> /// Juan Bautista /// </author> public MovementController() { this._profileTable = new ProfileTable("MovementProfiles"); this._movementTable = new MovementTable(); this._processTable = new ProcessesTable(); this._processDiagram = new ProcessDiagram(); this._authorizationTable = new AuthorizationTable(); this._userTable = new UserTable(); this._demandTable = new DemandTable(); }
public IActionResult PostAuthorizationTable(AuthorizationTable authorizationTable) { using (var scope = new TransactionScope()) { _admin1.AddDetail(authorizationTable); scope.Complete(); CreatedAtAction(nameof(GetAuthorizationTable), new { id = authorizationTable.EmpId }, authorizationTable); return(Ok()); } }
public ProcessController() { processesTable = new ProcessesTable(); movementTable = new MovementTable(); authorizationTable = new AuthorizationTable(); locationTable = new LocationTable(); hardwareTable = new HardwareTable(); rulesTable = new RulesTable(); hardwareReferenceTable = new HardwareReferenceTable(); validatepermissions = new validatePermissions(); }
public MovementProfileController() { this._profileTable = new ProfileTable("MovementProfiles"); this._movementTable = new MovementTable(); this._userTeble = new UserTable(); this._authorizationTable = new AuthorizationTable(); this._categoryTable = new CategoryTable(); validatepermissions = new validatePermissions(); this._processesTable = new ProcessesTable(); _logTable = new LogBook.Controllers.LogBookController(); }
public IActionResult Login(AuthorizationTable employee) { _log4net.Info("GetRequest() called with json input"); IActionResult response = Unauthorized(); var user = auth1.AuthenticateUser(employee); if (user != null) { var tokenstring = auth1.GenerateJSONWebToken(); response = Ok(new { token = tokenstring }); } return(response); }
public AuthorizationTable AuthenticateUser(AuthorizationTable authorization) { var user = _repo.GetAll(); foreach (var i in user) { if (i.UserName == authorization.UserName && i.Pswd == authorization.Pswd && i.EmpId == authorization.EmpId) { return(authorization); } } return(null); }
public void Login_WhenCalled_Unauthorized() { AuthorizationTable authorizationTable = new AuthorizationTable() { EmpId = "202", UserName = "******", Pswd = "1234" }; _auth1.Setup(r => r.AuthenticateUser(It.IsAny <AuthorizationTable>())).Returns(() => null); _auth1.Setup(r => r.GenerateJSONWebToken()).Returns("Token"); var result = _controller.Login(authorizationTable); Assert.That(result, Is.InstanceOf <UnauthorizedResult>()); }
public void Login_WhenCalled_ReturnsOk() { AuthorizationTable table = new AuthorizationTable() { UserName = "******", Pswd = "mansi", EmpId = "1" }; _auth1.Setup(r => r.AuthenticateUser(It.IsAny <AuthorizationTable>())).Returns(table); _auth1.Setup(r => r.GenerateJSONWebToken()).Returns("token"); var result = _controller.Login(table); Assert.That(result, Is.InstanceOf <OkObjectResult>()); }
public IActionResult Index(AuthorizationTable auth) { HttpClient client12 = cs.AuthClient(); var contentType = new MediaTypeWithQualityHeaderValue ("application/json"); client12.DefaultRequestHeaders.Accept.Add(contentType); string Data = JsonConvert.SerializeObject(auth); var contentData = new StringContent(Data, System.Text.Encoding.UTF8, "application/json"); HttpResponseMessage response = client12.PostAsync("api/Auth", contentData).Result; string jwtdata = response.Content.ReadAsStringAsync().Result; webtoken jwt = JsonConvert.DeserializeObject <webtoken>(jwtdata); if (jwt.Token == null) { return(RedirectToAction("Index")); } HttpContext.Session.SetString("token", jwt.Token); return(RedirectToAction("Access")); }