예제 #1
0
        /// <summary>登录后绑定当前用户</summary>
        public virtual OAuthLog BindAfterLogin(Int64 oauthId)
        {
            var prv  = Provider;
            var mode = nameof(BindAfterLogin);

            var user = prv.Current;

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

            var log = OAuthLog.FindById(oauthId);

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

            var uc = UserConnect.FindByID(log.ConnectId);

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

            uc.UserID     = user.ID;
            uc.Enable     = true;
            uc.UpdateTime = DateTime.Now;
            uc.Update();

            log.UserId = user.ID;
            log.SaveAsync();

            // 写日志
            LogProvider.Provider?.WriteLog(typeof(User), "绑定", true, $"[{user}]依据[{mode}]绑定到[{uc.Provider}]的[{uc.NickName}]", user.ID, user + "");

            return(log);
        }