void Awake()
        {
            // Called as soon as we can
            SetupProxy();

            if (tokenUpdated == null)
            {
                tokenUpdated = new TokenEvent();
            }
            if (authenticationFailed == null)
            {
                authenticationFailed = new FailureEvent();
            }
            if (userLoggedIn == null)
            {
                userLoggedIn = new UnityUserUnityEvent();
            }
            if (userLoggedOut == null)
            {
                userLoggedOut = new UnityEvent();
            }
            if (linkSharingDetected == null)
            {
                linkSharingDetected = new LinkSharingEvent();
            }
            if (openInViewerDetected == null)
            {
                openInViewerDetected = new OpenInViewerEvent();
            }

            ProjectServer.Init();

            authBackend = new AuthBackend(this);
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
            m_Interop = new Interop(this);
            m_Interop.Start();
#endif

            m_TokenPersistentPath = Path.Combine(Application.persistentDataPath, AuthConfiguration.JwtTokenFileName);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 登录
        /// </summary>
        public CustomerInfoModel DoLogin(CustomerLoginModel loginModel)
        {
            if (string.IsNullOrEmpty(loginModel.CorpId))
            {
                throw new Exception("公司代码不能为空");
            }
            //判断是否是商旅客户
            CorporationModel corporationModel = _corporationBll.GetCorpInfoByCorpId(loginModel.CorpId);

            if (corporationModel == null || string.IsNullOrEmpty(corporationModel.IsAmplitudeCorp) ||
                corporationModel.IsAmplitudeCorp.ToUpper() == "F")
            {
                throw new Exception("没有开通差旅功能,请联系客服开通");
            }

            //1.根据用户名,密码,公司代码,验证身份
            CustomerInfoModel customerInfo = _verifyBll.VerifyCustomer(loginModel);


            if (customerInfo == null)
            {
                return(null);
            }

            if (!string.IsNullOrEmpty(customerInfo.IsLock) && customerInfo.IsLock.ToUpper() == "T")
            {
                throw new Exception("该客户已经被冻结,请先解冻再登录");
            }
            if (!string.IsNullOrEmpty(customerInfo.IsDel) && customerInfo.IsDel.ToUpper() == "T")
            {
                throw new Exception("该客户已经被删除,无法登录");
            }

            //2.验证通过后,将token,UserId(key-value)保存到Redis中(事件方式)
            TokenEvent?.Invoke(this,
                               new TokenEventArgs(loginModel.Token, customerInfo.UserId, customerInfo.Cid, loginModel.ClientType));

            //当前个性化如果设置需要短信验证则IsCheckClientId为true
            if ((corporationModel?.IsNoteVerify ?? 0) == 0)
            {
                loginModel.IsCheckClientId = false;
            }
            else
            {
                loginModel.IsCheckClientId = true;
            }


            if (!(loginModel.IsCheckClientId ?? false) && !string.IsNullOrEmpty(loginModel.ClientId))
            {
                //3.更新设备id
                _addAppClientIdServiceBll.AddAppClientId(new AddAppClientIdModel()
                {
                    Cid        = customerInfo.Cid,
                    ClientId   = loginModel.ClientId,
                    ClientType = loginModel.ClientType
                });
            }

            //3.获取设备id
            loginModel.ClientId = _addAppClientIdServiceBll.GetAppClientId(customerInfo.Cid);



            return(customerInfo);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 登出
 /// </summary>
 /// <param name="token"></param>
 public void DoLoginOut(string token)
 {
     TokenEvent?.Invoke(this, new TokenEventArgs(token, "", 0, ""));
 }