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; }
protected override void OnCompleted(LoginCode code, string arguments, string UserId) { if (IsManual && WebWindow != null) { WebWindow.Close(); WebWindow = null; } base.OnCompleted(code, arguments, UserId); }
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); } }
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, }); }
/// <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; }
/// <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) { }
/// <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) { }