public CoordinatorUser ValidateUser(ZigBeeCoordinatorContext ctx, string userName, string password) { CoordinatorUser user = GetUserByUserName(ctx, userName); string hash = SecurityHelpers.GetMD5HashHexString(password); if (string.Equals(user.Password, hash, StringComparison.InvariantCultureIgnoreCase) || string.Equals(user.Password, password, StringComparison.InvariantCultureIgnoreCase)) { return(user); } return(null); }
private void FixupCoordinatorUser(CoordinatorUser previousValue) { if (previousValue != null && previousValue.UserSettings.Contains(this)) { previousValue.UserSettings.Remove(this); } if (CoordinatorUser != null) { if (!CoordinatorUser.UserSettings.Contains(this)) { CoordinatorUser.UserSettings.Add(this); } if (UserId != CoordinatorUser.UserId) { UserId = CoordinatorUser.UserId; } } }
public int?GetCurrentUserId() { object userIdObj = HttpContext.Current.Session["UserId"]; if (userIdObj is int) { return((int)userIdObj); } if (HttpContext.Current.Request.IsAuthenticated) { string userName = HttpContext.Current.User.Identity.Name; using (ZigBeeCoordinatorContext ctx = new ZigBeeCoordinatorContext()) { CoordinatorUser user = GetUserByUserName(ctx, userName); if (user != null) { user.UpdateSession(); return(user.UserId); } } } return(null); }