public JObject CreateNewUserObject(string userName, string email, string name, string password, UserIDType userType) { JObject customConfig = new JObject { [CommonConst.CommonField.DISPLAY_ID] = CommonUtility.GetNewID(), [CommonConst.CommonField.USER_TYPE] = userType.ToString(), [CommonConst.CommonField.IS_EMAIL_VALIDATE] = true, [CommonConst.CommonField.IS_ENABLED] = true }; customConfig[CommonConst.CommonField.DATA_KEY] = customConfig[CommonConst.CommonField.NAME] = customConfig[CommonConst.CommonField.EMAIL] = customConfig[CommonConst.CommonField.USER_ID] = userName; customConfig[CommonConst.CommonField.SALT_KEY] = CommonUtility.RandomString(19); customConfig[CommonConst.CommonField.PASSWORD] = _encryptionService.GetHash(password, customConfig[CommonConst.CommonField.SALT_KEY].ToString()); var claims = CreateUserDeafultClaims(userName, name, email); foreach (var claim in claims) { AddClaim(customConfig, claim.Key, claim.Value); } return(customConfig); }
protected bool CreateUser(string userid, string name, UserIDType userType) { JObject userData = new JObject(); userData[CommonConst.CommonField.USER_ID] = userData[CommonConst.CommonField.DATA_KEY] = userid; userData[CommonConst.CommonField.USER_TYPE] = userType.ToString(); var updateFilter = userData.ToString(); userData[CommonConst.CommonField.DISPLAY_ID] = CommonUtility.GetNewID(); userData[CommonConst.CommonField.IS_ENABLED] = true; userData[CommonConst.CommonField.NAME] = name; userData[CommonConst.CommonField.IS_EMAIL_VALIDATE] = false; userData[CommonConst.CommonField.IS_PHONE_VALIDATE] = false; var userGroup = AppSettingService.GetAppSetting(ModuleAppConsts.Field.DEFAULT_USER_GROUPS_APP_SETTING_KEY); Logger.Debug("userGroup setting data", userGroup); if (userGroup == null) { throw new Exception("User Group setting not found in AppSettings"); } if (userGroup[CommonConst.CommonField.DATA] == null || userGroup[CommonConst.CommonField.DATA][CommonConst.CommonField.USER_GROUPS] == null) { throw new Exception("User Groups not found in AppSettings"); } userData[CommonConst.CommonField.USER_GROUPS] = (userGroup[CommonConst.CommonField.DATA][CommonConst.CommonField.USER_GROUPS] as JArray); return(DBProxy.Write(CommonConst.Collection.USERS, userData, updateFilter, true)); }
protected UserModel GetUserDataFromRequest(JObject request) { UserModel user = new UserModel(); user.user_id = request[CommonConst.CommonField.USER_ID].ToString(); var userIdTypeStr = request[CommonConst.CommonField.USER_TYPE].ToString(); UserIDType userIdType = UserIDType.PhoneNumber; Enum.TryParse <UserIDType>(userIdTypeStr, out userIdType); user.user_type = userIdType.ToString(); return(user); }
public static bool CreateUser(IDBService dbProxy, IAppSettingService appSettingService, string userid, UserIDType userType, string name, string email, string picture) { JObject userData = new JObject(); userData[CommonConst.CommonField.USER_ID] = userData[CommonConst.CommonField.DATA_KEY] = userid; userData[CommonConst.CommonField.USER_TYPE] = userType.ToString(); var updateFilter = userData.ToString(); userData[CommonConst.CommonField.DISPLAY_ID] = CommonUtility.GetNewID(); userData[CommonConst.CommonField.IS_ENABLED] = true; userData[CommonConst.CommonField.NAME] = name; userData[CommonConst.CommonField.EMAIL] = email; userData[CommonConst.CommonField.IS_EMAIL_VALIDATE] = userType == UserIDType.Google ? true : false; userData[CommonConst.CommonField.IS_PHONE_VALIDATE] = false; var userGroup = appSettingService.GetAppSetting(ModuleAppConsts.Field.DEFAULT_USER_GROUPS_APP_SETTING_KEY); if (userGroup == null) { throw new Exception("User Group setting not found in AppSettings"); } if (userGroup[CommonConst.CommonField.DATA] == null || userGroup[CommonConst.CommonField.DATA][CommonConst.CommonField.USER_GROUPS] == null) { throw new Exception("User Groups not found in AppSettings"); } userData[CommonConst.CommonField.USER_GROUPS] = (userGroup[CommonConst.CommonField.DATA][CommonConst.CommonField.USER_GROUPS] as JArray); if (dbProxy.Write(CommonConst.Collection.USERS, userData, updateFilter, true)) { var userInfo = new JObject(); userInfo[CommonConst.CommonField.USER_ID] = userid; var filter = userInfo.ToString(); userInfo[CommonConst.CommonField.USER_PIC] = picture; var dbresponse = dbProxy.Update(CommonConst.Collection.USER_INFO, filter, userInfo, true, MergeArrayHandling.Merge); return(dbresponse == 1); } else { return(false); } }