예제 #1
0
        public async Task <IHttpActionResult> GuestLogin([FromBody] AccountLoginInfo info)
        {
            Logger.Info("Account.GuestLogin");

            var    r = new Random();
            string accountNamePostfix = r.Next(0, 1000000).ToString("D6");
            string accountName        = $"uc_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}_{accountNamePostfix}";
            string token    = EncryptHashManager.GenerateToken();
            string password = Guid.NewGuid().ToString();

            var account = new AccountEntity
            {
                AccountName     = accountName,
                IsGuest         = true,
                Password        = EncryptHashManager.ComputeHash(password),
                Token           = EncryptHashManager.GenerateToken(),
                CreatedDateTime = DateTime.UtcNow
            };

            await this.DatabaseContext.Bucket.InsertSlimAsync(account);

            var response = new AccountGuestLoginResponse
            {
                AccountId   = account.Id,
                AccountName = accountName,
                Token       = token,
                Password    = password
            };

            return(CreateSuccessResult(response));
        }
예제 #2
0
        public async Task <IHttpActionResult> GuestLogin([FromBody] AccountLoginInfo info, CancellationToken token)
        {
            CustomTrace.TraceInformation("Account.GuestLogin");

            var    r = new Random();
            string accountNamePostfix = r.Next(0, 1000000).ToString("D6");
            string accountName        = $"uc_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}_{accountNamePostfix}";
            string accountToken       = EncryptHashManager.GenerateToken();
            string password           = Guid.NewGuid().ToString();

            var account = new AccountEntity
            {
                Id          = Guid.NewGuid().ToString(),
                AccountName = accountName,
                IsGuest     = true,
                Password    = EncryptHashManager.ComputeHash(password),
                Token       = EncryptHashManager.GenerateToken()
            };

            await this.Database.Accounts.InsertAsync(account, token);

            var response = new AccountGuestLoginResponse
            {
                AccountId   = account.Id,
                AccountName = accountName,
                Token       = accountToken,
                Password    = password
            };

            return(this.CreateSuccessResult(response));
        }
예제 #3
0
    //-------------------------------------------------------------------------
    void _onUCenterGuestLogin(UCenterResponseStatus status, AccountGuestLoginResponse response, UCenterError error)
    {
        EbLog.Note("ClientSampleApp._onUCenterGuestLogin() UCenterResult=" + status);

        if (error != null)
        {
            EbLog.Note("ErrorCode=" + error.ErrorCode);
            EbLog.Note("ErrorMessage=" + error.Message);
        }
        else
        {
            EbLog.Note("AccountId=" + response.AccountId);
            EbLog.Note("AccountName=" + response.AccountName);
        }
    }
예제 #4
0
        //-------------------------------------------------------------------------
        void _uCenterGuestCallBack(UCenterResponseStatus status, AccountGuestLoginResponse response, UCenterError error)
        {
            if (status == UCenterResponseStatus.Success)
            {
                if (mGuestPlayerInfo == null)
                {
                    mGuestPlayerInfo = new _tGuestPlayerInfo();
                }

                mGuestPlayerInfo.account_id   = response.AccountId;
                mGuestPlayerInfo.account_name = response.AccountName;
                mGuestPlayerInfo.pwd          = response.Password;
                PlayerPrefs.SetString(mGuestPlayerKey, EbTool.jsonSerialize(mGuestPlayerInfo));

                _requestLogin(mGuestPlayerInfo.account_name, mGuestPlayerInfo.pwd);
            }
            else if (error != null)
            {
                //if (error.ErrorCode == GF.UCenter.Common.Portable.UCenterErrorCode.AccountRegisterFailedAlreadyExist)
                //{
                //    FloatMsgInfo f_info;
                //    f_info.msg = "帐号已存在";
                //    f_info.color = Color.red;
                //    UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info);
                //}
                //UiHelper.DestroyWaiting();
                Debug.LogError(string.Format("_uCenterGuestCallBack::Error::ErrorCode::{0} ErrorMsg::{1}", error.ErrorCode.ToString(), error.Message));
            }
            else
            {
                //FloatMsgInfo f_info;
                //f_info.msg = "注册失败";
                //f_info.color = Color.red;
                //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info);
                //UiHelper.DestroyWaiting();
            }
        }