Beispiel #1
0
 public Models.TbLogin ParaTabela(Models.Request.LoginRequest req)
 {
     return(new Models.TbLogin {
         DsEmail = req.Email,
         DsSenha = req.Senha
     });
 }
        public Models.TbLogin ParaLoginTabela(Models.Request.LoginRequest req)
        {
            Models.TbLogin tb = new Models.TbLogin();
            tb.DsEmail = req.Email;
            tb.DsSenha = req.Senha;

            return(tb);
        }
Beispiel #3
0
        /*- Login -*/

        public Models.TbLogin ToLoginTable(Models.Request.LoginRequest req)
        {
            Models.TbLogin resp = new Models.TbLogin();
            resp.DsEmail = req.Email;
            resp.DsSenha = req.Senha;

            return(resp);
        }
        public Models.TbUsuario Logar(Models.Request.LoginRequest loginRequest)
        {
            Models.TbUsuario usuario = ctx.TbUsuario.FirstOrDefault(x => x.DsEmail
                                                                    == loginRequest.Email && x.DsSenha
                                                                    == loginRequest.Senha);

            return(usuario);
        }
Beispiel #5
0
 public Models.TbLogin ConsultarLogin(Models.Request.LoginRequest user)
 {
     return(
         bd.TbLogin.Include(x => x.IdClienteNavigation).Include(x => x.IdFuncionarioNavigation)
         .FirstOrDefault(x => x.DsEmail == user.usuario &&
                         x.DsEmail == user.senha)
         );
 }
        public Models.TbLogin ToTbLogin(Models.Request.LoginRequest req)
        {
            Models.TbLogin tb = new Models.TbLogin();
            tb.DsEmail    = req.Email;
            tb.DsSenha    = req.Senha;
            tb.DtUltLogin = DateTime.Now;

            return(tb);
        }
        public Models.TbLogin ParaTbLogin(Models.Request.LoginRequest request)
        {
            Models.TbLogin tbLogin = new Models.TbLogin();

            tbLogin.DsEmail = request.Email;
            tbLogin.DsSenha = request.Senha;

            return(tbLogin);
        }
        public Models.TbLogin ParaTbLogin(Models.Request.LoginRequest req)
        {
            Models.TbLogin tb = new Models.TbLogin();

            tb.DsEmail = req.email;
            tb.DsSenha = req.senha;

            return(tb);
        }
Beispiel #9
0
        public async Task <ActionResult> Login([FromBody] Models.Request.LoginRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            await loginUseCase.Handle(new LoginRequest(request.UserName, request.Password), loginPresenter);

            return(loginPresenter.ContentResult);
        }
    //[ValidateAntiForgeryToken]
    public async Task <ActionResult> Login([FromBody] Models.Request.LoginRequest request)
    {
        if (!ModelState.IsValid)
        {
            return(BadRequest(ModelState));
        }
        LoginResponse response = await _mediator.Send(new LoginCommand(request.UserName, request.Password, Request.HttpContext.Connection.RemoteIpAddress?.ToString()));

        return(_mapper.Map <JsonContentResult>(response));
    }
Beispiel #11
0
        public async Task <ActionResult> Login([FromBody] Models.Request.LoginRequest request)
        {
            if (!ModelState.IsValid)
            { // re-render the view when validation failed.
                return(BadRequest(ModelState));
            }
            await _loginUseCase.Handle(new LoginRequest(request.UserName, request.Password), _loginPresenter);

            return(_loginPresenter.ContentResult);
        }
Beispiel #12
0
        public async Task <ActionResult> Login([FromBody] Models.Request.LoginRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            await _loginUseCase.Handle(new LoginRequest(request.UserName, request.Password, Request.HttpContext.Connection.RemoteIpAddress?.ToString()), _loginPresenter);

            return(_loginPresenter.ContentResult);
        }
Beispiel #13
0
        public Models.TbLogin ParaTabelaFunc(int idADM, Models.Request.LoginRequest req)
        {
            Models.TbLogin login = new Models.TbLogin();
            if (new Database.LoginDatabase().ConsultarID(idADM).NrNivel >= 3)
            {
                login.NrNivel = 1;
            }
            login.DsEmail = req.Email;
            login.DsSenha = req.Senha;

            return(login);
        }
Beispiel #14
0
        public async Task <ActionResult <Models.Response.LoginResponse> > FazerLogin(Models.Request.LoginRequest req)
        {
            try
            {
                Models.TbLogin tb = await business.RealizarLogin(conversor.ParaTbLogin(req));

                return(conversor.ParaResponse(tb));
            }
            catch (Exception ex)
            {
                return(BadRequest(new Models.Response.ErroResponse(ex, 400)));
            }
        }
        public Models.TbLogin Logar(Models.Request.LoginRequest user)
        {
            if (string.IsNullOrEmpty(user.usuario))
            {
                throw new ArgumentException("Usuario não informado.");
            }

            if (string.IsNullOrEmpty(user.senha))
            {
                throw new ArgumentException("Senha não informada.");
            }

            return(funcaoDatabase.ConsultarLogin(user));
        }
Beispiel #16
0
 [HttpPost] // Cliente e Funcionario
 public ActionResult <Models.Response.LoginResponse> Consultar(Models.Request.LoginRequest req)
 {
     try
     {
         Models.TbLogin login = conv.ParaTabela(req);
         return(conv.ParaResponse(buss.Consultar(login)));
     }
     catch (Exception ex)
     {
         return(new BadRequestObjectResult(
                    new Models.Response.ErrorResponse(ex.Message, 400)
                    ));
     }
 }
Beispiel #17
0
 [HttpPost("Funcionario/{idADM}")] // Adm
 public ActionResult CadastrarFuncionario(int idADM, Models.Request.LoginRequest req)
 {
     try
     {
         Models.TbLogin login = conv.ParaTabelaFunc(idADM, req);
         return(new OkResult());
     }
     catch (Exception ex)
     {
         return(new BadRequestObjectResult(
                    new Models.Response.ErrorResponse(ex.Message, 400)
                    ));
     }
 }
        public Models.TbLogin Logar(Models.Request.LoginRequest loginRequest)
        {
            validador.ValidarEmail(loginRequest.Email);

            validador.ValidarStrings(loginRequest.Senha, "senha");

            Models.TbLogin login = dbLogin.PegarLoginUsuario(loginRequest.Email, loginRequest.Senha);

            if (login == null)
            {
                throw new ArgumentException("Nenhum Registo Encontrado!!!");
            }

            return(login);
        }
Beispiel #19
0
        public ActionResult <Models.Response.LoginResponse> Logar(Models.Request.LoginRequest loginRequest)
        {
            try
            {
                Models.TbLogin login = business.Logar(loginRequest);

                return(conversor.ParaLoginResponse(login));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new Models.Response.ErroResponse(
                                      ex.Message, 400
                                      )));
            }
        }
        public ActionResult <Models.Response.LogadoResponse> Logar(Models.Request.LoginRequest loginRequest)
        {
            try
            {
                Models.TbUsuario usuario = business.Logar(loginRequest);

                Models.Response.LogadoResponse logadoResponse = conversor.ParaLogadoResponse(usuario);

                return(logadoResponse);
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new Models.Response.ErroResponse(
                                      400, ex.Message
                                      )));
            }
        }
Beispiel #21
0
        public async Task <ActionResult> Login([FromBody] Models.Request.LoginRequest request)
        {
            try
            {
                if (!ModelState.IsValid)
                { // re-render the view when validation failed.
                    return(BadRequest(ModelState));
                }

                await _loginUseCase.Handle(new LoginRequest(request.Email, HashPasswordUseCase.Execute(request.Password)), _loginPresenter);

                return(_loginPresenter.ContentResult);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Beispiel #22
0
        public ActionResult <Models.Response.LoginResponse> Logar(Models.Request.LoginRequest loginRequest)
        {
            try
            {
                Models.TbLogin tbLogin = loginConversor.ParaTbLogin(loginRequest);
                tbLogin = business.Logar(tbLogin);

                Models.Response.LoginResponse resp = loginConversor.ParaLoginResponse(tbLogin);

                return(resp);
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new Models.Response.ErroResponse(
                                      400, ex.Message
                                      )));
            }
        }
        public ActionResult <Models.Response.LoginResponse> Login(Models.Request.LoginRequest req)
        {
            try
            {
                Models.TbLogin loginTb = cnv.ToLoginTable(req);

                loginTb = bsn.Login(loginTb);

                Models.Response.LoginResponse resp = cnv.ToLoginResponse(loginTb);

                return(resp);
            }
            catch (Exception e)
            {
                return(BadRequest(
                           new Models.Response.ErroResponse(e.Message, 400)
                           ));
            }
        }
Beispiel #24
0
        public ActionResult <Models.Response.LoginResponse> Login(Models.Request.LoginRequest req)
        {
            try
            {
                Models.TbLogin tb = conv.ParaLoginTabela(req);

                tb = busi.Login(tb);

                Models.Response.LoginResponse resp = conv.ParaLoginResponse(tb);

                return(resp);
            }
            catch (Exception ex)
            {
                return(BadRequest(
                           new Models.Response.ErroResponse(400, ex.Message)
                           ));
            }
        }
        public Models.TbUsuario Logar(Models.Request.LoginRequest loginRequest)
        {
            if (string.IsNullOrEmpty(loginRequest.Email))
            {
                throw new ArgumentException("O e-mail é obrigatório.");
            }

            if (string.IsNullOrEmpty(loginRequest.Senha))
            {
                throw new ArgumentException("A senha é obrigatória.");
            }

            Models.TbUsuario usuario = dbLogin.Logar(loginRequest);

            if (usuario == null)
            {
                throw new ArgumentException("Nenhum registro encontrado!");
            }

            return(usuario);
        }
        public async Task <ActionResult <Models.Response.LoginResponse> > LoginAsync(Models.Request.LoginRequest req)
        {
            try
            {
                Models.TbLogin tbLoginAtual  = usuarioCnv.ToCadastrarTbLogin(req.Email, req.Senha);
                Models.TbLogin tbLoginAntigo = await usuarioBsn.ConsultarLoginPorEmailAsync(req.Email);

                tbLoginAntigo = await usuarioBsn.LoginAsync(tbLoginAtual);

                tbLoginAtual = await usuarioBsn.AtualizarLoginAsync(tbLoginAntigo, tbLoginAtual);

                Models.Response.LoginResponse resp = usuarioCnv.ToLoginResponse(tbLoginAtual);

                return(resp);
            }
            catch (Exception ex)
            {
                return(BadRequest(
                           new Models.Response.ErroResponse(400, ex.Message)
                           ));
            }
        }
        public async Task <IActionResult> Login([FromBody] Models.Request.LoginRequest request)
        {
            await _accountsHandler.LogInAsync(new LoginRequestDTO(request.UserName, request.Password), _loginPresenter);

            return(_loginPresenter.Result);
        }
 public Models.Response.LoginResponse AlterarLogin(int idlogin, Models.Request.LoginRequest novo)
 {
     Models.TbLogin login    = Conversor.Convert(novo);
     Models.TbLogin alterado = funcaoBusiness.AlterarLogin(idlogin, login);
     return(Conversor.Convert(AlterarLogin));
 }
 public Models.Response.LoginResponse Logar(Models.Request.LoginRequest dados)
 {
     Models.TbLogin user = funcaoBusiness.Logar(dados);
     return(Convesor.Convert(user));
 }
Beispiel #30
0
        public async Task <IActionResult> Authenticate([FromBody] Models.Request.LoginRequest request)
        {
            var result = new TokenResponse();

            try
            {
                #region .: request validation :.

                if (request == null)
                {
                    throw new ApplicationException("Request cannot be null!");
                }
                if (string.IsNullOrEmpty(request.Login))
                {
                    throw new ApplicationException("Login cannot be null");
                }
                if (string.IsNullOrEmpty(request.Password))
                {
                    throw new ApplicationException("Password cannot be null");
                }
                var user = await _userRepository.FindByLogin(request.Login);

                if (user == null)
                {
                    throw new ApplicationException($"User {request.Login} not found!");
                }

                var password = SecurityUtils.Encrypt(request.Password, user.Saltkey);
                if (!user.Password.Equals(password))
                {
                    throw new ApplicationException($"Invalid Login or Password!");
                }

                #endregion

                var token = new Domain.Models.Tokens
                {
                    Token        = Guid.NewGuid().ToString(),
                    UserId       = user.Id,
                    DtExpiration = DateTime.UtcNow.AddDays(1),
                    Active       = true,
                    DtCreated    = DateTime.UtcNow
                };

                await base.InternalPost(token);

                return(Ok(TokenResponse.FromModel(token, user)));
            }
            catch (ApplicationException ex)
            {
                LogUtils.Add("TokensController.Authenticate", ex);
                result.Message = ex.Message;
                result.Success = false;
                return(BadRequest(result));
            }
            catch (UnauthorizedAccessException ex)
            {
                LogUtils.Add("TokensController.Authenticate", ex);
                result.Message = this.OOPS_ACCESS_DENIED;
                result.Success = false;
                return(Unauthorized(result));
            }
            catch (Exception ex)
            {
                LogUtils.Add("TokensController.Authenticate", ex);
                result.Message = this.OOPS_ERROR_MESSAGE;
                result.Success = false;
                return(NotFound(result));
            }
        }