コード例 #1
0
 public ResponseUserLogin(LoginCode code, string msg, int uid, string passport, string secureKey) : this()
 {
     this.Code      = code;
     this.Msg       = msg;
     this.Uid       = uid;
     this.Passport  = passport;
     this.SecureKey = secureKey;
 }
コード例 #2
0
 protected override void OnCompleted(LoginCode code, string arguments, string UserId)
 {
     if (IsManual && WebWindow != null) {
         WebWindow.Close();
         WebWindow = null;
     }
     base.OnCompleted(code, arguments, UserId);
 }
コード例 #3
0
 protected override void OnCompleted(LoginCode code, string arguments, string UserId)
 {
     if (IsManual && WebWindow != null)
     {
         WebWindow.Close();
         WebWindow = null;
     }
     base.OnCompleted(code, arguments, UserId);
 }
コード例 #4
0
        protected virtual void OnCompleted(LoginCode code, string arguments, string UserId)
        {
            LoginCompleteEventArgs args = new LoginCompleteEventArgs(code, arguments, UserId);

            if (LogManager != null)
            {
                LogManager.InfoFormat("Logging in completed: code={0}, result=\"{1}\", user={2}", code, arguments, UserId);
            }
            if (LoginCompleted != null)
            {
                LoginCompleted(this, args);
            }
        }
コード例 #5
0
ファイル: authController.cs プロジェクト: l-l-0/CenterService
        private async Task <LoginResult> TryLoginAsync(LoginCode code, User find, string ip)
        {
            if (code == LoginCode.Ok)
            {
                // 默认单人登录
                var single      = (mongo.SystemConfigCollection.AsQueryable().Where(s => s.Key == $"{ip}:SingleAuth").Select(s => s.JObject).FirstOrDefault() ?? "true").Equals("true", StringComparison.OrdinalIgnoreCase);
                var isFirstUser = false;
                var primary     = ServiceStartup.GetPrimaryAuthorized(ip);
                var token       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff");

                var menuId      = mongo.RoleCollection.AsQueryable().FirstOrDefault(r => r.Users.Contains(find.UniqueId) && r.DefaultMenu != null)?.DefaultMenu ?? null;
                var menu        = mongo.MenuCollection.AsQueryable().FirstOrDefault(f => f.UniqueId == menuId);
                var defaultMenu = menu == null ? null : $"/{menu.ParentId}/{menu.Uri}";

                if (primary == null)
                {
                    isFirstUser = true;
                    primary     = new AuthorizedUserCache
                    {
                        UniqueId    = find.UniqueId,
                        LoginId     = find.LoginId,
                        DisplayName = find.Employee?.DisplayName ?? find.LoginId,
                        Kernel      = false,
                        Token       = token,
                        DefaultMenu = defaultMenu,
                    };
                    await ServiceStartup.SetPrimaryAuthorizedAsync(ip, primary);
                }

                if (single)
                {
                    await mongo.AccessJournalCollection.InsertOneAsync(new AccessJournal { Computer = ip, UserId = primary.LoginId, UserName = primary.DisplayName, });

                    return(new LoginResult {
                        Code = code, Jwt = token, Menu = defaultMenu, Ip = ip,
                    });
                }

                if (!isFirstUser)
                {
                    if (find.LoginId == primary.LoginId)
                    {
                        return(new LoginResult {
                            Code = LoginCode.DuplicateLogin, Ip = ip,
                        });
                    }

                    await ServiceStartup.SetSecondaryAuthorizedAsync(ip, new AuthorizedUserCache
                    {
                        UniqueId    = find.UniqueId,
                        LoginId     = find.LoginId,
                        DisplayName = find.Employee?.DisplayName ?? find.LoginId,
                        Kernel      = false,
                        Token       = token,
                        DefaultMenu = defaultMenu,
                    });

                    await mongo.AccessJournalCollection.InsertOneAsync(new AccessJournal { Computer = ip, UserId = primary.LoginId, UserName = primary.DisplayName, });

                    await mongo.AccessJournalCollection.InsertOneAsync(new AccessJournal { Computer = ip, UserId = find.LoginId, UserName = find.DisplayName, });

                    return(new LoginResult {
                        Code = code, Jwt = token, Menu = defaultMenu, Ip = ip,
                    });
                }
            }

            return(new LoginResult {
                Code = code, Ip = ip,
            });
        }
コード例 #6
0
 protected virtual void OnCompleted(LoginCode code, string arguments, string UserId)
 {
     LoginCompleteEventArgs args = new LoginCompleteEventArgs(code, arguments, UserId);
     if (LogManager != null) {
         LogManager.InfoFormat("Logging in completed: code={0}, result=\"{1}\", user={2}", code, arguments, UserId);
     }
     if (LoginCompleted != null) {
         LoginCompleted(this, args);
     }
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of <see cref="LoginCompleteEventArgs"/> for specified <see cref="LoginCode"/>, arguments and user name.
 /// </summary>
 /// <param name="Code">Login code</param>
 /// <param name="Arguments">Arguments</param>
 /// <param name="UserName">User name</param>
 public LoginCompleteEventArgs(LoginCode Code, string Arguments, string UserName)
 {
     this.Code = Code;
     this.Arguments = Arguments;
     this.UserName = UserName;
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of <see cref="LoginCompleteEventArgs"/> for specified <see cref="LoginCode"/> and arguments.
 /// </summary>
 /// <param name="Code">Login code</param>
 /// <param name="Arguments">Arguments</param>
 public LoginCompleteEventArgs(LoginCode Code, string Arguments)
     : this(Code, Arguments, string.Empty)
 {
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of <see cref="LoginCompleteEventArgs"/> for specified <see cref="LoginCode"/>.
 /// </summary>
 /// <param name="Code">Login code</param>
 public LoginCompleteEventArgs(LoginCode Code)
     : this(Code, string.Empty)
 {
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of <see cref="LoginCompleteEventArgs"/> for specified <see cref="LoginCode"/> and arguments.
 /// </summary>
 /// <param name="Code">Login code</param>
 /// <param name="Arguments">Arguments</param>
 public LoginCompleteEventArgs(LoginCode Code, string Arguments)
     : this(Code, Arguments, string.Empty)
 {
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of <see cref="LoginCompleteEventArgs"/> for specified <see cref="LoginCode"/>.
 /// </summary>
 /// <param name="Code">Login code</param>
 public LoginCompleteEventArgs(LoginCode Code)
     : this(Code, string.Empty)
 {
 }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of <see cref="LoginCompleteEventArgs"/> for specified <see cref="LoginCode"/>, arguments and user name.
 /// </summary>
 /// <param name="Code">Login code</param>
 /// <param name="Arguments">Arguments</param>
 /// <param name="UserName">User name</param>
 public LoginCompleteEventArgs(LoginCode Code, string Arguments, string UserName)
 {
     this.Code      = Code;
     this.Arguments = Arguments;
     this.UserName  = UserName;
 }