Exemplo n.º 1
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            if (actionContext == null)
            {
                throw new ArgumentNullException("actionContext");
            }

            //if (actionContext.Request.Method.Method != "GET")
            //{
            var headers = actionContext.Request.Headers;

            //string val = actionContext.Request.Headers.GetValues("hkey").First();
            var tokenHeader = string.Empty;

            if (headers.Contains("hkey"))
            {
                tokenHeader = headers.GetValues("hkey").First();
                if (tokenHeader != "admin")
                {
                    HeadertokenModel objl = new HeadertokenModel();
                    objl.Ftype = "4";
                    objl.Token = tokenHeader;
                    try
                    {
                        string status = new LoginHelper().SaveToken_Login(objl);
                        if (status.Equals("Success"))
                        {
                        }
                        else
                        {
                            actionContext.Response = get_status("Another User is Login With Same Credentials");
                            //throw new UnauthorizedAccessException();
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.ToString().Contains("ORA-12520:"))
                        {
                            actionContext.Response = get_status("Server is busy Please try again some other time");
                        }
                        else
                        {
                            actionContext.Response = get_status(ex.Message.ToString());
                        }
                    }
                }
            }

            // AntiForgery.Validate(tokenCookie != null ? tokenCookie.Value : null, tokenHeader);
            //}

            base.OnActionExecuting(actionContext);
        }
Exemplo n.º 2
0
        public dynamic GetPSLogOut(dynamic data)
        {
            string jsondata = token_gen.Authorize_aesdecrpty(data);

            //string jsondata = JsonConvert.SerializeObject(data); //token_gen.Authorize_aesdecrpty(data);
            try
            {
                HeadertokenModel val = JsonConvert.DeserializeObject <HeadertokenModel>(jsondata);

                return(Ok(_Loginhel.SaveToken_Login(val)));
            }
            catch (Exception ex)
            {
                _response.Status = 102;
                _response.Reason = _Loginhel.ErrorMessage;
                return(Ok(_response));
            }
        }