public ActionResult LoginConfirm([FromBody] JsonElement LoginJson)
        {
            try
            {
                //Crypto?
                var        content      = JsonConvert.DeserializeObject <LoginModel>(LoginJson.GetRawText());
                LoginModel SavedContent = _login.GetUserByUserName(content.UserName);
                if (SavedContent == null)
                {
                    SavedContent = _login.GetUser(content.UserName);
                }
                if (SavedContent == null)
                {
                    return(NotFound());
                }

                //salting
                bool loginResult = false;
                if (HashSalt(content.Password, Convert.FromBase64String(_salt.GetUserById(SavedContent.Id).SaltPass)).Pass == SavedContent.Password)
                {
                    loginResult = true;
                }
                return(Ok(loginResult));
            }
            catch (Exception e)
            {
                throw new Exception($"Error Code 1.2 - Error at HTTPPOST - {e.Message}");
            }
        }
Beispiel #2
0
        public ActionResult Confirm([FromBody] JsonElement js)
        {
            try
            {
                var result    = false;
                var content   = JsonConvert.DeserializeObject <RecoveryPost>(js.GetRawText());
                var userLogin = _login.GetUserByUserName(content.UserName);
                //finds user depending on given username or email
                if (userLogin == null)
                {
                    userLogin = _login.GetUser(content.Email);
                }

                //confirms match
                if (userLogin.Recovery.Contains(content.RecoveryPass))
                {
                    result = true;
                    userLogin.Recovery.Remove(content.RecoveryPass);
                    //Removes used recov pass
                    _login.Update(userLogin.UserName, userLogin);
                }
                return(Ok(result));
            }
            catch
            {
                throw new Exception("Error code 5.2 - Error at RecoveryController Post");
            }
        }