Example #1
0
        public IActionResult Token([FromBody] LoginModel loginModel)
        {
            Log.Debug("in authenticate: login=" + loginModel.Login);

            if (string.IsNullOrEmpty(loginModel.Password) || string.IsNullOrEmpty(loginModel.Login))
            {
                return(BadRequest());
            }

            loginModel.Password = MD5GEnerator.GetMD5(loginModel.Password);

            var user = _userRepo.Authorize(loginModel);

            if (user == null)
            {
                return(BadRequest());
            }

            var token = _tokenBuilder.Generate(user);

            Log.Debug(token);

            return(Ok(token));
        }