Exemplo n.º 1
0
        public HttpResponseMessage GetProfile()
        {
            //Verifico se l'utente che esegue la richiesta è autorizzato
            bool isAuth = IdentityHelper.IsAuthenticated();

            //Se il client non è autorizzato, lo notifico
            if (!isAuth)
            {
                Request.CreateResponse(HttpStatusCode.Unauthorized);
            }

            string username = IdentityHelper.GetUsername();

            IList <Claim> claims = IdentityHelper.FetchClaims().ToList();

            //Compongo il dto in uscita
            object dto = new
            {
                IsAuth = isAuth,
                Claims = claims,
                // ImgProfilePath = !string.IsNullOrWhiteSpace(picturePath) ? Url.Content(picturePath) : string.Empty,
                ImgProfilePath = String.Empty,
                Username       = username,
                Email          = IdentityHelper.GetEmail()
            };

            //ritorno il contesto di validazione
            return(Request.CreateResponse(HttpStatusCode.OK, dto));
        }