Ejemplo n.º 1
0
 public IActionResult UserLoggedIn([FromBody] Token token)
 {
     try
     {
         if (Request.Headers.ContainsKey("X-XamarinKey"))
         {
             if (UserManagementService.CheckXamarinKey(Request.Headers["X-XamarinKey"]))
             {
                 User user      = JsonConvert.DeserializeObject <User>(token.Object_To_Server);
                 var  userToken = UserManagementService.UserAccessToken(user.Email);
                 if (userToken != null)
                 {
                     return(Ok(userToken));
                 }
                 else
                 {
                     string custom_token = UserManagementService.addNewUser(user);
                     return(Ok(custom_token));
                 }
             }
             else
             {
                 return(Unauthorized("Unauthorized"));
             }
         }
         else
         {
             return(Unauthorized("Unauthorized"));
         }
     }
     catch (Exception e)
     {
         return(BadRequest("Invalid object"));
     }
 }