示例#1
0
        public string Get()
        {
            var    re       = this.Request;
            var    headers  = re.Headers;
            string username = "";
            string password = "";

            try
            {
                username = headers.GetCommaSeparatedValues("username").First();
                password = headers.GetCommaSeparatedValues("username").First();
            }
            catch (Exception e)
            {
            }
            User buffer = userManager.checkUser(username, password);

            userManager.GenerateToken(buffer);
            buffer = userManager.checkUser(username, password);
            clientUser userToSend = new clientUser
            {
                Username = buffer.Username,
                Token    = buffer.Token
            };

            string json = JsonSerializer.Serialize(userToSend);

            return(json);
        }
示例#2
0
        public bool Delete(clientUser UserID)
        {
            serverUserModel SUM = Users.Where(t => t.ID == UserID.ID).FirstOrDefault();

            if (SUM != null)
            {
                Users.Remove(SUM);
                return(true);
            }

            return(false);
        }
示例#3
0
        public bool Update(clientUser user)
        {
            serverUserModel SUM = Users.Where(t => t.ID == user.ID).FirstOrDefault();

            if (SUM != null)
            {
                SUM.Name     = user.Name;
                SUM.Username = user.Username;
                return(true);
            }

            return(false);
        }
        public IActionResult Post([FromBody] clientLoginModel value)
        {
            LoginCheck checkLogin      = new LoginCheck();
            clientUser clientUserModel = checkLogin.Check(value);

            if (clientUserModel != null)
            {
                return(Ok(clientUserModel));
            }
            else
            {
                return(BadRequest("Invalid Username or Password"));
            }
        }