private void Events_UserAfterCreate(UserAfterCreateEventArgs args) { List <SystemNotificationPreference> defaults = DefaultSystemNotifications.GetSystemNotificationPreferences(); if (defaults != null && defaults.Count > 0) { ApiList <NotificationDistributionTypeInfo> distributionTypes = PublicApi.Notifications.ListDistributionTypes(); ApiList <NotificationTypeInfo> notificationTypes = PublicApi.Notifications.ListNotificationTypes(); foreach (NotificationTypeInfo notificationType in notificationTypes) { foreach (NotificationDistributionTypeInfo distributionType in distributionTypes) { SystemNotificationPreference preference = ( from p in defaults where p.NotificationTypeId == notificationType.NotificationTypeId && p.DistributionTypeId == distributionType.DistributionTypeId select p).FirstOrDefault(); if (preference != null) { PublicApi.Users.RunAsUser(args.Id.Value, () => PublicApi.Notifications.UpdatePreference(preference.NotificationTypeId, preference.DistributionTypeId, preference.IsEnabled)); } else { PublicApi.Users.RunAsUser(args.Id.Value, () => PublicApi.Notifications.UpdatePreference(notificationType.NotificationTypeId, distributionType.DistributionTypeId, false)); } } } } }
private void Events_UserAfterCreate(UserAfterCreateEventArgs args) { List<SystemNotificationPreference> defaults = DefaultSystemNotifications.GetSystemNotificationPreferences(); if (defaults != null && defaults.Count > 0) { ApiList<NotificationDistributionTypeInfo> distributionTypes = PublicApi.Notifications.ListDistributionTypes(); ApiList<NotificationTypeInfo> notificationTypes = PublicApi.Notifications.ListNotificationTypes(); foreach (NotificationTypeInfo notificationType in notificationTypes) { foreach (NotificationDistributionTypeInfo distributionType in distributionTypes) { SystemNotificationPreference preference = ( from p in defaults where p.NotificationTypeId == notificationType.NotificationTypeId && p.DistributionTypeId == distributionType.DistributionTypeId select p).FirstOrDefault(); if (preference != null) { PublicApi.Users.RunAsUser(args.Id.Value, () => PublicApi.Notifications.UpdatePreference(preference.NotificationTypeId, preference.DistributionTypeId, preference.IsEnabled)); } else { PublicApi.Users.RunAsUser(args.Id.Value, () => PublicApi.Notifications.UpdatePreference(notificationType.NotificationTypeId, distributionType.DistributionTypeId, false)); } } } } }
private void Events_AfterUserCreate(UserAfterCreateEventArgs e) { var afterCreatedCookie = CookieHelper.GetCookie(SamlCookieName); if (afterCreatedCookie == null) { return; } var samlTokenData = SamlTokenData.GetTokenDataFromDatabase(afterCreatedCookie.Value); if (samlTokenData == null) { return; } //destroy secure cookie for new user if cookie is still present CookieHelper.DeleteCookie(afterCreatedCookie.Value); //also cleanup our afterCreatedCookie CookieHelper.DeleteCookie(afterCreatedCookie.Name); //update the samlTokenData now that we know the user ID and cleanup the cookie used by the login samlTokenData.UserId = e.Id.Value; //Update the cookie SAMLToken Data to have the UserId now that its an existing user to fire the after authenticated events (which also removes the cookie) var tokenKey = samlTokenData.SaveTokenDataToDatabase(); var afterAuthenticatedCookie = new HttpCookie(clientType, tokenKey) { Expires = DateTime.Now.AddHours(8), HttpOnly = true }; CookieHelper.AddCookie(afterAuthenticatedCookie); if (PersistClaims) { SqlData.SaveSamlToken(samlTokenData); } var apiUser = _usersApi.Get(new UsersGetOptions() { Id = e.Id.Value }); //raise new SamlUserCreated Event try { SamlEvents.Instance.OnAfterUserCreate(apiUser, samlTokenData); } catch (Exception ex) { _eventLogApi.Write("SamlOAuthClient Error OnAfterUserCreate: " + ex.Message + " : " + ex.StackTrace, new EventLogEntryWriteOptions() { Category = "SAML", EventId = 1, EventType = "Error" }); } }
private void EventsOnAfterCreate(UserAfterCreateEventArgs userAfterCreateEventArgs) { //Find all of the joinless groups with forums and set the default subscription for this user PublicApi.JobService.Schedule(typeof(SubscriptionUpdateJob) ,DateTime.UtcNow, new Dictionary<string,string>() { {"UserName" , userAfterCreateEventArgs.Username}, {"processForums" , bool.TrueString}, {"processBlogs" , bool.TrueString}, {"processCalendars" , bool.TrueString}, {"processGroups", bool.TrueString} }); }
private void EventsOnAfterCreate(UserAfterCreateEventArgs userAfterCreateEventArgs) { //Find all of the joinless groups with forums and set the default subscription for this user PublicApi.JobService.Schedule(typeof(SubscriptionUpdateJob), DateTime.UtcNow, new Dictionary <string, string>() { { "UserName", userAfterCreateEventArgs.Username }, { "processForums", bool.TrueString }, { "processBlogs", bool.TrueString }, { "processCalendars", bool.TrueString }, { "processGroups", bool.TrueString } }); }