Ejemplo n.º 1
0
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            if (actionContext.Request.Headers.Authorization == null)
            {
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
            }
            else
            {
                var tokenkey   = actionContext.Request.Headers.Authorization.Parameter;
                var jsonstring = FTH.Extension.Encrypter.Decrypt(tokenkey, "1");
                var perso      = Newtonsoft.Json.JsonConvert.DeserializeObject <Personeller>(jsonstring);

                Personeller pers = ValidationControl.IsPersonel(perso.Adi, perso.SoyAdi);

                if (pers != null)
                {
                    Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(pers.Adi), null);
                }
                else
                {
                    actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
                }
            }

            base.OnAuthorization(actionContext);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Get([FromUri] string name, [FromUri] string surname)
        {
            var Perso = ValidationControl.IsPersonel(name, surname);

            if (Perso != null)
            {
                //UserNorth u = new UserNorth();
                //u.name = Perso.Adi;
                //u.surname = Perso.SoyAdi;
                var    jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(Perso);
                string token   = FTH.Extension.Encrypter.Encrypt(jsonstr, "159357");
                return(Request.CreateResponse(HttpStatusCode.OK, token));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Giriş yapılan bilgilere sahip personel bulunmamaktadır."));
            }
        }