コード例 #1
0
        public string Post([FromBody] LoginRequest login)
        {
            CSC425Context db              = new CSC425Context();
            var           apikey          = Request.Query["api_key"].ToString();
            var           remoteIPAddress = HttpContext.Features.Get <IHttpConnectionFeature>()?.RemoteIpAddress.ToString();

            if (apikey.Length == 0)
            {
                return(login.SessionIDOverride(db, remoteIPAddress));
            }

            if (apikey.ToLower() != Security.APIKey.ToLower())
            {
                return(JsonConvert.SerializeObject(new ReturnCode(401, "Unauthorized", "Bad API Key")));
            }

            return(login.AttemptLogin(db, remoteIPAddress));
        }