Exemple #1
0
 public static async Task <IActionResult> HttpExtensionsJwtAuth2(
     [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
     [HttpToken] HttpUser user,
     ILogger log)
 {
     return(new OkResult());
 }
Exemple #2
0
 public static async Task <IActionResult> UserData(
     [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "userdata")] HttpRequest req,
     [HttpToken] HttpUser user,
     ILogger log)
 {
     return(new OkObjectResult(new MyUser()
     {
         Id = user.ClaimsPrincipal.Identity.Name, NickName = user.ClaimsPrincipal.Claims.First(x => x.Type == "nickname").Value
     }));
 }
Exemple #3
0
 public static async Task <IActionResult> HttpExtensionsJwtAuth1(
     [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
     [HttpToken] HttpUser user,
     ILogger log)
 {
     return(new OkObjectResult(new
     {
         user = user.ClaimsPrincipal.Identity.Name
     }));
 }
        public async Task <IActionResult> Send(string username, string message)
        {
            var user = new HttpUser {
                Ip       = LocalIp,
                Username = username,
                Message  = message
            };
            var f = new FormUrlEncodedContent(user.ToDictionary());

            foreach (var clientIp in ClientsIps)
            {
                await Client.PostAsync("http://localhost:5000/Home/Store/", f);
            }
            return(Json("Sent"));
        }
 public void Store(HttpUser infos)
 {
     HttpContext.Session.SetObjectAsJson($"infos.Username", infos);
 }