示例#1
0
        public async Task <IActionResult> WGOpenIdLoginAsync(string region,
                                                             [FromQuery(Name = "openid.assoc_handle")] string assocHandle,
                                                             [FromQuery(Name = "openid.claimed_id")] string claimedId)
        {
            try
            {
                var verification = _wgOpenId.VerifyLogin(RegionExtensions.FromString(region), claimedId, assocHandle, HttpContext.Request.Query);
                if (verification is null)
                {
                    return(BadRequest());
                }
                else
                {
                    (long id, string nickname) = ((long, string))verification;

                    var player = await _warshipsApi.GetPlayerInfoAsync(RegionExtensions.FromString(region), id);

                    _user.Login(player);
                    return(RedirectToReferer());
                }
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(new { Reason = ex.Message }));
            }
            catch
            {
                return(StatusCode(500));
            }
        }
示例#2
0
 public IActionResult GetWGOpenIdRequestBody(string region)
 {
     try
     {
         return(Ok(_wgOpenId.GetRequestBody(RegionExtensions.FromString(region), $"{_settings.BaseUrl}Account/WGOpenId/Login/{region}")));
     }
     catch (Exception ex)
     {
         return(Error(ex));
     }
 }