public ActionResult EditOperatorLogin(int Id)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }

            ViewBag.Logout = Session["Username"].ToString().ToUpper();
            ViewBag.roleid = Session["RoleID"];
            String Username = Session["Username"].ToString();

            using (i_facility_shaktiEntities1 db = new i_facility_shaktiEntities1())
            {
                tblOperatorLoginDetail operatorLoginDetail = db.tblOperatorLoginDetails.Find(Id);
                if (operatorLoginDetail == null)
                {
                    return(HttpNotFound());
                }

                ViewBag.Roles          = new SelectList(db.tblroles.Where(m => m.IsDeleted == 0 && (m.Role_ID == 6 || m.Role_ID == 9)), "Role_ID", "RoleName", operatorLoginDetail.roleId).ToList();
                ViewBag.machineDetails = new SelectList(db.tblmachinedetails.Where(m => m.IsDeleted == 0), "MachineID", "MachineName").ToList();
                ViewBag.mac            = String.Join(",", db.tblOperatorMachineDetails.Where(m => m.isDeleted == 0 && m.operatorLoginId == operatorLoginDetail.operatorLoginId).Select(m => m.machineId).ToList());
                OperatorLogin op = new OperatorLogin();
                op.operatorLogin = operatorLoginDetail;
                return(View(op));
            }
        }
Esempio n. 2
0
        public ActionResult Signup(OperatorLogin viewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    WebSecurity.CreateUserAndAccount(viewModel.Operator.Email, viewModel.RegisterModel.Password, new
                    {
                        Discriminator = "Operator",
                        Name          = viewModel.Operator.Name
                    });
                    WebSecurity.Login(viewModel.Operator.Email, viewModel.RegisterModel.Password);
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", AccountController.ErrorCodeToString(e.StatusCode));
                }
                var cl =
                    from s in _db.Operators
                    where s.Email == viewModel.Operator.Email
                    select s;

                var op = cl.First();

                op.Contact1         = viewModel.Operator.Contact1;
                op.TypeOfBusiness   = viewModel.Operator.TypeOfBusiness;
                op.Description      = viewModel.Operator.Description;
                _db.Entry(op).State = EntityState.Modified;
                _db.SaveChanges();

                return(RedirectToAction("Index", "OperatorsView"));
            }

            return(View(viewModel));
        }
        public async Task NotLoginPasswordWrong()
        {
            var user = new Operator()
            {
                Id           = 0,
                Name         = "user-test",
                Registration = "test-registration",
                Password     = "******"
            };
            await _repository.Add(user);

            Exception exception     = null;
            var       operatorLogin = new OperatorLogin()
            {
                Password      = "******",
                Resgistration = user.Registration
            };

            try
            {
                await this._service.Login(operatorLogin, new FakeAuthentication());
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.AreNotEqual(exception, null);
        }
        public async Task OperatorLoginSucess()
        {
            var user = new Operator()
            {
                Id           = 0,
                Name         = "user-test",
                Registration = "test-registration",
                Password     = "******"
            };
            await _repository.Add(user);

            Exception   exception     = null;
            OperatorJWT clientJWT     = null;
            var         operatorLogin = new OperatorLogin()
            {
                Password      = user.Password,
                Resgistration = user.Registration
            };

            try
            {
                clientJWT = await this._service.Login(operatorLogin, new FakeAuthentication());
            }
            catch (UserNotDefinid ex)
            {
                exception = ex;
            }

            Assert.AreEqual(exception, null);
            Assert.AreEqual(clientJWT.Token, "token-implementation-fake");
        }
 public async Task<OperatorJwt> Login(OperatorLogin userLogin, IToken token)
 {
     IPerson loggedPerson = await personRepository.FindByDocumentAndPassword<Operator>(userLogin.Registration, userLogin.Password, Convert.ToInt16(PersonRole.Operator));
     if (loggedPerson == null) throw new EntityNotFound("Documento e senha inválidos");
     return new OperatorJwt()
     {
         Id = loggedPerson.Id,
         Name = loggedPerson.Name,
         Registration = loggedPerson.Document,
         Role = loggedPerson.Role.ToString(),
         Token = token.GerarToken(loggedPerson)
     };
 }
Esempio n. 6
0
 public async Task <ActionResult> Login([FromBody] OperatorLogin user)
 {
     try
     {
         return(StatusCode(200, await _clientLogin.Login(user, new Authentication())));
     }
     catch (UserNotFound err)
     {
         return(StatusCode(401, new {
             Message = err.Message
         }));
     }
 }
Esempio n. 7
0
 public async Task <ActionResult> OperatorLogin(OperatorLogin userLogin)
 {
     try
     {
         return(StatusCode(200, await _personService.Login(userLogin, new Token())));
     }
     catch (EntityNotFound err)
     {
         return(StatusCode(401, new
         {
             Message = err.Message
         }));
     }
 }
        public async Task <OperatorJWT> Login(OperatorLogin user, IToken token)
        {
            var loggedUser = await _repository.FindByRegistrationAndPassword(user.Resgistration, user.Password);

            if (loggedUser == null)
            {
                throw new UserNotFound("Usuário ou senha inválidos.");
            }
            return(new OperatorJWT()
            {
                Id = loggedUser.Id,
                Name = loggedUser.Name,
                Registration = loggedUser.Registration,
                Role = loggedUser.UserRole.ToString(),
                Token = token.TokenGenerateOperator(loggedUser)
            });
        }
        // GET: OperatorLoginDetails

        public ActionResult Index()
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"].ToString().ToUpper();
            ViewBag.roleid = Session["RoleID"];
            String Username           = Session["Username"].ToString();
            tblOperatorLoginDetail pa = new tblOperatorLoginDetail();
            OperatorLogin          mp = new OperatorLogin();

            //ViewBag.Roles = new SelectList(db.tblroles.Where(m => m.IsDeleted == 0), "RoleId", "RoleName", pa.roleId).ToList();
            mp.operatorLogin     = pa;
            mp.operatorLoginList = db.tblOperatorLoginDetails.Where(m => m.isDeleted == 0).ToList();
            //ViewBag.Role = new SelectList(db.tblroles.Where(m => m.IsDeleted == 0), "RoleId", "RoleName").ToList();
            return(View(mp));
        }
        public async Task NotLoginUserNotExist()
        {
            var operatorLogin = new OperatorLogin()
            {
                Password      = "******",
                Resgistration = "not-exist"
            };
            Exception exception = null;

            try{
                await this._service.Login(operatorLogin, new FakeAuthentication());
            }catch (Exception ex)
            {
                exception = ex;
            }


            Assert.AreNotEqual(exception, null);
        }