public static bool setPasswordHash(this TMUser tmUser, string passwordHash) { if (tmUser.notNull() && passwordHash.valid()) { tmUser.SecretData.PasswordHash = passwordHash; tmUser.AccountStatus.PasswordExpired = false; tmUser.event_User_Updated(); //tmUser.saveTmUser(); return(true); } return(false); }
public static Guid passwordResetToken_getTokenAndSetHash(this TMUser tmUser) { if (tmUser.notNull()) { var newToken = Guid.NewGuid(); tmUser.SecretData.PasswordResetToken = tmUser.passwordResetToken_getHash(newToken); tmUser.event_User_Updated(); //tmUser.saveTmUser(); return(newToken); } return(Guid.Empty); }
/*public static UserActivity logUserActivity (this UserActivities userActivities, string who, string action, string detail) { var userActivity = userActivities.newUserActivity(who,action,detail); return userActivities.logUserActivity(userActivity, null); } */ public static UserActivity logUserActivity(this UserActivities userActivities, UserActivity userActivity, TMUser tmUser) { if (userActivities.notNull() && userActivity.notNull()) { if(userActivities.logging_Enabled()) { userActivities.ActivitiesLog.add_Activity(userActivity); userActivity.firebase_Log(); if (tmUser.notNull() && tmUser.ID != Guid.Empty) { tmUser.UserActivities.add_Activity(userActivity); tmUser.event_User_Updated(); //tmUser.saveTmUser(); } } } return userActivity; }
/*public static UserActivity logUserActivity (this UserActivities userActivities, string who, string action, string detail) * { * var userActivity = userActivities.newUserActivity(who,action,detail); * return userActivities.logUserActivity(userActivity, null); * } */ public static UserActivity logUserActivity(this UserActivities userActivities, UserActivity userActivity, TMUser tmUser) { if (userActivities.notNull() && userActivity.notNull()) { if (userActivities.logging_Enabled()) { userActivities.ActivitiesLog.add_Activity(userActivity); userActivity.firebase_Log(); if (tmUser.notNull() && tmUser.ID != Guid.Empty) { tmUser.UserActivities.add_Activity(userActivity); tmUser.event_User_Updated(); //tmUser.saveTmUser(); } } } return(userActivity); }
public static bool updateTmUser(this TMUser tmUser, TM_User user) { if (tmUser.isNull()) { return(false); } if (tmUser.UserName == user.UserName) { tmUser.EMail = user.Email; //Encoder.XmlEncode(user.Email); // these encodings should now be enfored on TBOT (and the user does not see them) tmUser.UserName = user.UserName; //Encoder.XmlEncode(user.UserName); // they were causing double encoding isues on the new TBOT editor tmUser.FirstName = user.FirstName; //Encoder.XmlEncode(user.FirstName); tmUser.LastName = user.LastName; //Encoder.XmlEncode(user.LastName); tmUser.Title = user.Title; //Encoder.XmlEncode(user.Title); tmUser.Company = user.Company; //Encoder.XmlEncode(user.Company); tmUser.Country = user.Country; //Encoder.XmlEncode(user.Country); tmUser.State = user.State; //Encoder.XmlEncode(user.State); tmUser.UserTags = user.UserTags; tmUser.GroupID = user.GroupID > -1 ? user.GroupID : tmUser.GroupID; tmUser.AccountStatus.ExpirationDate = user.ExpirationDate.ToLocalTime(); tmUser.AccountStatus.PasswordExpired = user.PasswordExpired; tmUser.AccountStatus.UserEnabled = user.UserEnabled; tmUser.AccountStatus.AccountNeverExpires = user.AccountNeverExpires; if (tmUser.UserTags.notEmpty()) { foreach (var userTag in tmUser.UserTags) { if (userTag.validation_Failed()) { tmUser.logUserActivity(String.Format("Failing to update user {0} because UserTags validation failed.", tmUser.UserName), ""); return(false); } } } tmUser.event_User_Updated(); //tmUser.saveTmUser(); tmUser.logUserActivity("User Updated", ""); // so that we don't get this log entry on new user creation return(true); } "[updateTmUser] provided username didn't match provided tmUser or validation failed".error(); return(false); }