Exemplo n.º 1
0
        public async Task <User> Login([FromBody] User userInfo)
        {
            if (await accountsRepository.ValidateUserAsync(userInfo.Username, HashGenerator.GenerateHash(userInfo.Password)))
            {
                var user = await accountsRepository.GetUserAsync(userInfo.Username);

                try
                {
                    HttpContext.Session.Set("User", Converter.Instance().ObjectToByteArray(user));
                }
                catch (Exception e)
                {
                    var x = e.Message;
                }

                return(user);
            }
            return(null);
        }