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));
        }
Esempio n. 2
0
 public Task Save(W3CUserAuthentication user)
 {
     return(Upsert(user));
 }
        public IActionResult GetUserInfo([FromQuery] string jwt)
        {
            var user = W3CUserAuthentication.FromJWT(jwt, JwtPublicKey);

            return(user != null ? (IActionResult)Ok(user) : Unauthorized("Sorry Hackerboi"));
        }