public async Task <ActionResult <TokenModel> > Login([FromBody] AccountRequest request)
        {
            try
            {
                var script     = new scriptPass();
                var buildToken = new BuildToken();

                request.Password = script.script(request.Password);

                var model = await _manager.getByEmail(request.Email);

                if (model == null)
                {
                    BadRequest("Invalid  User");
                }

                if (request.Email != model.Email || request.Password != model.Password)
                {
                    return(BadRequest("Invalid Password"));
                }

                return(buildToken.UserToken(model.Email));
            }catch (Exception ex)
            {
                ex.Message.ToString();
                return(BadRequest());
            }
        }
Exemple #2
0
        public async Task <TokenModel> Login([FromBody] AccountRequest request)
        {
            var script     = new scriptPass();
            var buildToken = new BuildToken();

            request.Password = script.script(request.Password);

            var model = await _manager.getByEmail(request.Email);

            if (model == null)
            {
                BadRequest("Invalid User");
            }

            if (model.Email != request.Email || model.Password != request.Password)
            {
                BadRequest("Invalid Password");
            }

            return(buildToken.UserToken(model.Email));
        }