Esempio n. 1
0
        public async Task <IActionResult> GetBlizzardToken([FromQuery] string code, [FromQuery] string redirectUri)
        {
            var token = await _authenticationService.GetToken(code, redirectUri);

            if (token == null)
            {
                return(Unauthorized("Sorry H4ckerb0i"));
            }

            var userInfo = await _registrationHandler.GetUserOrRegister(token.access_token);

            if (userInfo == null)
            {
                return(Unauthorized("Sorry H4ckerb0i"));
            }

            var w3User = await _w3CAuthenticationService.GetUserById(userInfo.battletag);

            if (w3User == null)
            {
                var w3CUserAuthentication = W3CUserAuthentication.Create(userInfo.battletag);
                await _w3CAuthenticationService.Save(w3CUserAuthentication);

                return(Ok(w3CUserAuthentication));
            }

            return(Ok(w3User));
        }
        public async Task <IActionResult> GetBlizzardToken(
            [FromQuery] string code,
            [FromQuery] string redirectUri,
            [FromQuery] BnetRegion region)
        {
            var token = await _blizzardAuthenticationService.GetToken(code, redirectUri, region);

            if (token == null)
            {
                return(Unauthorized("Sorry H4ckerb0i"));
            }

            var userInfo = await _blizzardAuthenticationService.GetUser(token.access_token, region);

            if (userInfo == null)
            {
                return(Unauthorized("Sorry H4ckerb0i"));
            }

            var w3User = W3CUserAuthentication.Create(userInfo.battletag, JwtPrivateKey);

            return(Ok(w3User));
        }
        public async Task <IActionResult> GetBlizzardToken([FromQuery] string code, [FromQuery] string redirectUri)
        {
            var token = await _authenticationService.GetToken(code, redirectUri);

            return(token == null ? (IActionResult)Unauthorized("Sorry H4ckerb0i") : Ok(token));
        }