private void ManageUsersToolStripMenuItem1_Click(object sender, EventArgs e) { // NOTE: ONLY SUPERADMIN HAS THE RIGHT TO INVOKE THIS METHOD #if !DEBUG if (_loginUser.Type != TypeUser.SuperAdmin) { return; } #endif // TODO: this should be precomputed var userContext = new LoginUserContext { ID = _loginUser.Id, Name = _loginUser.Name, MachineName = Environment.MachineName, LoginTime = DateTime.Now, // Incorrect! VoteDbContext = DbUtils.AppEntities }; using (EditUserSettings formEditUsers = new EditUserSettings(userContext)) { if (formEditUsers.ShowDialog(this) == DialogResult.OK) { } } }
public async Task <ActionResult <RequestResult> > Login([FromBody] LoginRequestParameter parameter) { if (!ModelState.IsValid) { return(RequestResult.CreateErrorResult("")); } var now = DateTime.Now; var userInfo = await service.GetUserByLoginInfo(parameter.LoginId, parameter.Password); if (userInfo == null) { return(RequestResult.CreateErrorResult("ユーザーIDまたはパスワードが間違っています。")); } var claims = new List <Claim> { new Claim(ClaimTypes.Name, userInfo.UserNo.ToString()) }; ClaimsPrincipal principal = new ClaimsPrincipal(new ClaimsIdentity(claims, "login")); //一度ログアウト・セッションのクリアを行う。 await HttpContext.SignOutAsync(Startup.AuthScheme); HttpContext.Session.Clear(); //ログイン処理 await HttpContext.SignInAsync(Startup.AuthScheme, principal, new AuthenticationProperties() { //IsPersistent = true }); //セッションにユーザ情報をセットする。 var context = new LoginUserContext(userInfo); HttpContext.Session.Set <LoginUserContext>(LoginUserContext.InSessionKey, context); //セッションにアプリケーション情報をセットする。 var appInfo = await appService.GetApplicationInfo(); var appContext = new ApplicationContext(appInfo); HttpContext.Session.Set <ApplicationContext>(ApplicationContext.InSessionKey, appContext); string redirectUrl = ""; //ReturnUrlはjavascript側でurlから取得して設定している。 if (!string.IsNullOrEmpty(parameter.ReturnUrl) && Url.IsLocalUrl(parameter.ReturnUrl)) { redirectUrl = new PathString(parameter.ReturnUrl); } return(RequestResult.CreateSuccessResult(new { RedirectUrl = redirectUrl })); }
public EditUserSettings(LoginUserContext userContext) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; Paint += (sender, e) => { // draw top banner SolidBrush primaryBrush = new SolidBrush(Configurations.PartieInfo.PrimaryColor); SolidBrush secondaryBrush = new SolidBrush(Configurations.PartieInfo.SecondaryColor); // draw bottom banner e.Graphics.FillRectangle(primaryBrush, 0, 0, Width, 25); e.Graphics.FillRectangle(secondaryBrush, 0, ClientRectangle.Height - 25, Width, 25); }; _userContext = userContext; MaximizeBox = false; //this.SetMAxSize(); InitUI(); }
public LoginService(LoginUserContext loginUserContext) { _context = loginUserContext; }
public AuthRoleHandler(LoginUserContext loginContext) { this.LoginContext = loginContext; }
/// <summary> /// 设置缓存 /// </summary> /// <param name="key"></param> /// <param name="obj"></param> public void Set(string loginID, LoginUserContext context) { _Set(loginID, context); }
public UserService(LoginUserContext context) { _context = context; }
public AuditLogFilter(LoginUserContext loginContext, string appId, ILogger <AuditLogFilter> logger) { this.loginContext = loginContext; this.appId = appId; this.logger = logger; }
public AuthDivisionHandler(LoginUserContext loginContext) { this.LoginContext = loginContext; }
public UserAccountService(LoginUserContext loginUserContext) { _loginUserContext = loginUserContext; }