Ejemplo n.º 1
0
        public async Task <IActionResult> PostPointsToDevice(string id, [FromBody] TrackingPoint[] points)
        {
            var subject  = ClaimsReader.ReadSubject(this.User);
            var audience = ClaimsReader.ReadAudience(this.User);

            if (audience == JwtAuthConstants.DeviceAudience && id != subject)
            {
                return(Forbid());
            }

            points.ForEach((point) => point.TrackingDeviceId = id);
            var addedPoints = await this.pointService.AddAsync(points);

            await this.geoFenceService.HandlePoints(addedPoints.First().AssetId, addedPoints.ToArray());

            return(Ok());
        }
        public async Task <IActionResult> LoginCallback(string redirectUri = "")
        {
            var email = ClaimsReader.ReadEmail(this.User);

            if (email == null)
            {
                throw new UnknownProviderException();
            }

            var user = await this.userService.GetOrCreateUserByEmailAsync(
                email,
                ClaimsReader.ReadName(this.User),
                ClaimsReader.ReadSubject(this.User));

            if (string.IsNullOrWhiteSpace(redirectUri))
            {
                return(Ok());
            }
            else
            {
                return(Redirect(redirectUri));
            }
        }