Exemplo n.º 1
0
 public HttpResponseMessage Authentificate(HttpRequestMessage request, [FromBody] CredentialsData viewModel)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (_oktaProvider.ValidateUser(viewModel.Email, viewModel.Password))
         {
             try
             {
                 var principal = Thread.CurrentPrincipal as EzePrincipal;
                 if (principal != null)
                 {
                     var userData = new SimpleUserData(principal.UserId, principal.Login, principal.Identity.Name,
                                                       principal.CompanyId, principal.MemeberName);
                     response = request.CreateResponse(HttpStatusCode.OK,
                                                       new { userData = userData, loginSuccess = true });
                 }
             }
             catch (Exception ex)
             {
                 response = request.CreateResponse(HttpStatusCode.OK,
                                                   new { loginSuccess = false, message = ex.Message });
             }
         }
         else
         {
             response = request.CreateResponse(HttpStatusCode.OK,
                                               new { loginSuccess = false, message = HttpContext.Current.Items["authnError"] });
         }
         return response;
     }));
 }
Exemplo n.º 2
0
 public void BindAccount(Action <bool> isSuccess)
 {
     Debug.Log("绑定帐号");
     open.Login(() =>
     {
         if (open.IsLoggedIn)
         {
             GameMainManager.instance.netManager.GetIsBind(open.token.userId, (ret, res) =>
             {
                 if (res.errcode == -1)//未绑定
                 {
                     Debug.Log("未绑定");
                     SimpleUserData user = LocalDatasManager.loggedGuest;
                     if (user == null)
                     {
                         isSuccess(false);
                     }
                     else
                     {
                         Binding(user);
                     }
                 }
                 else
                 {
                     LoginGameServer(open.token.tokenString);
                 }
             });
         }
         else
         {
             isSuccess(false);
         }
     });
 }
Exemplo n.º 3
0
 private void Binding(SimpleUserData user)
 {
     Debug.Log("正在绑定facebook帐号");
     GameMainManager.instance.netManager.BindAccount(user.uuid, open.token.tokenString, (ret, res) =>
     {
         if (res.isOK)
         {
             SimpleUserData simpleUser       = new SimpleUserData();
             simpleUser.name                 = res.data.name;
             simpleUser.level                = res.data.crowns;
             LocalDatasManager.loggedAccount = simpleUser;
             LocalDatasManager.loggedGuest   = null;
         }
         OnLoginComplateHandle(res);
     });
 }
Exemplo n.º 4
0
    /// <summary>
    /// 平台登录
    /// </summary>
    /// <param name="accessToken"></param>
    private void LoginGameServer(string accessToken)
    {
        Debug.Log("登录游戏服务器");
        EventDispatcher.instance.DispatchEvent(new LoadingEvent("Login", 0.3f));
        GameMainManager.instance.netManager.LoginFB(accessToken, (ret, res) =>
        {
            if (res.isOK)
            {
                SimpleUserData simpleUser       = new SimpleUserData();
                simpleUser.name                 = res.data.name;
                simpleUser.level                = res.data.crowns;
                LocalDatasManager.loggedAccount = simpleUser;
            }

            OnLoginComplateHandle(res);
        });
    }
Exemplo n.º 5
0
    public void OnClickGuestLogin()
    {
        loadingTips.text = "";
        facebookBtn.SetActive(false);
        guesBtn.SetActive(false);

        SimpleUserData accountData = LocalDatasManager.loggedAccount;

        if (accountData != null)
        {
            loginTipPanel.SetActive(true);
            userNameText.text = string.Format("姓名:{0}", accountData.name);
            levelText.text    = string.Format("等级:{0}", accountData.level);
        }
        else
        {
            LoginGuest();
        }
    }
Exemplo n.º 6
0
    public void LoginGuest(string name = "")
    {
        Debug.Log("游客登录");
        SimpleUserData guest = LocalDatasManager.loggedGuest;

        if (guest == null)
        {
            guest      = new SimpleUserData();
            guest.uuid = Guid.NewGuid().ToString("N");
            if (string.IsNullOrEmpty(name))
            {
                guest.name = "游客_" + UnityEngine.Random.Range(0, 100000000).ToString();
            }
            else
            {
                guest.name = name;
            }

            LocalDatasManager.loggedGuest = guest;
        }


        LoginGameServer(guest.uuid, guest.name);
    }