public JObject Auth() { var request = HttpProxy.GetRequestBody <JObject>(); if (request[AUTH_TOKEN] == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } var authToken = request[AUTH_TOKEN].ToString(); if (isOauthVerification) { return(ValidateOAuthTokenCreateUser(authToken)); } else { if (request[CommonConst.CommonField.USER_ID] == null || request[CommonConst.CommonField.NAME] == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } Logger.Debug(string.Format("User id:{0}, Name:{1}, AuthToken:{2}", request[CommonConst.CommonField.USER_ID].ToString(), request[CommonConst.CommonField.NAME].ToString(), authToken)); if (CreateUser(request[CommonConst.CommonField.USER_ID].ToString(), request[CommonConst.CommonField.NAME].ToString(), UserIDType.Facebook)) { return(CreateSesssion(authToken, request[CommonConst.CommonField.USER_ID].ToString())); } else { return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } } }
public JObject Update() { try { JObject request = HttpProxy.GetRequestBody <JObject>(); if (request == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } if (request[CommonConst.CommonField.DISPLAY_ID] == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } JObject filter = new JObject(); filter[CommonConst.CommonField.DISPLAY_ID] = request[CommonConst.CommonField.DISPLAY_ID].ToString(); var dbresponse = DBProxy.Update(CommonConst.Collection.APP_SETTING, filter.ToString(), request, true, MergeArrayHandling.Replace); if (dbresponse == 0) { Logger.Error(string.Format("Error in SettingController.update: {0}, collection {1}", "Error in updating data in db", CommonConst.Collection.APP_SETTING)); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS)); } catch (Exception ex) { Logger.Error(string.Format("SettingController.Get {0}", ex.Message), ex); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } }
public JObject MyProfileUpdate() { JObject request = HttpProxy.GetRequestBody <JObject>(); if (request == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } string userId = string.Empty; if (request[CommonConst.CommonField.USER_ID] != null) { userId = request[CommonConst.CommonField.USER_ID].ToString(); } var userData = SessionProvider.GetValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY); if (userData == null) { Logger.Debug("User session data is null"); return(ResponseBuilder.CreateReponse(CommonConst._401_UNAUTHORIZED)); } if (userData.user_id != userId) { Logger.Debug("User id conflict with session data"); return(ResponseBuilder.CreateReponse(CommonConst._401_UNAUTHORIZED)); } return(AdminUpdate()); }
public JObject AdminUpdate() { try { Logger.Debug("Enter to UpdateUserInfo.AdminUpdate"); JObject request = HttpProxy.GetRequestBody <JObject>(); if (request == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } string userId = string.Empty; if (request[CommonConst.CommonField.USER_ID] != null) { userId = request[CommonConst.CommonField.USER_ID].ToString(); } if (string.IsNullOrEmpty(userId)) { Logger.Error(string.Format("Error in UpdateUserInfo.AdminUpdate: {0}", "User id empty")); return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } JObject updateFilter = new JObject(); updateFilter[CommonConst.CommonField.USER_ID] = userId; if (request[ModuleAppConsts.Field.USER_INFO] != null && (request[ModuleAppConsts.Field.USER_INFO] as JArray).Count > 0) { var userInfo = request[ModuleAppConsts.Field.USER_INFO][0] as JObject; Logger.Debug("Updating User Info", userInfo); var dbresponse = DBProxy.Update(CommonConst.Collection.USER_INFO, updateFilter.ToString(), userInfo, true, MergeArrayHandling.Replace); if (dbresponse == 0) { Logger.Error(string.Format("Error in UpdateUserInfo.AdminUpdate: {0}, collection {1}", "Error in updating data in db", CommonConst.Collection.USER_INFO)); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } } JObject userdata = new JObject(); userdata[CommonConst.CommonField.PHONE] = request[CommonConst.CommonField.PHONE]; userdata[CommonConst.CommonField.EMAIL] = request[CommonConst.CommonField.EMAIL]; userdata[CommonConst.CommonField.NAME] = request[CommonConst.CommonField.NAME]; Logger.Debug("Updating User", userdata); if (DBProxy.Write(CommonConst.Collection.USERS, userdata, updateFilter.ToString(), false, MergeArrayHandling.Union)) { return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS, updateFilter)); } else { Logger.Error(string.Format("Error in UpdateUserInfo.AdminUpdate: {0}, collection {1}", "Error in updating data in db", CommonConst.Collection.USERS)); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } } catch (Exception ex) { Logger.Error(string.Format("Error in UpdateUserInfo.AdminUpdate: {0}", ex.Message), ex); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } }
public JObject UpdateAlbum() { try { var galleryId = HttpProxy.GetQueryString(ImageProcessor.GALLERY_ID); var requestBody = HttpProxy.GetRequestBody <JObject>(); if (requestBody == null || string.IsNullOrEmpty(galleryId)) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } if (!ImageGalleryHelper.IsOwner(DBProxy, SessionProvider, galleryId)) { return(ResponseBuilder.CreateReponse(CommonConst._401_UNAUTHORIZED)); } var filter = new JObject(); filter[CommonConst.CommonField.DISPLAY_ID] = galleryId; var data = DBProxy.FirstOrDefault(ImageProcessor.MYPHOTO_GALLERY_COLLECTION, filter.ToString()); if (data == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } if (requestBody[ImageProcessor.DISPLAY_NAME] != null) { data[ImageProcessor.DISPLAY_NAME] = requestBody[ImageProcessor.DISPLAY_NAME].ToString(); } if (requestBody[ImageProcessor.DESCRIPTION] != null) { data[ImageProcessor.DESCRIPTION] = requestBody[ImageProcessor.DESCRIPTION].ToString(); } if (requestBody[ImageProcessor.GALLERY_THUMBNAIL] != null) { data[ImageProcessor.GALLERY_THUMBNAIL] = requestBody[ImageProcessor.GALLERY_THUMBNAIL].ToString(); } if (requestBody[ImageProcessor.AUTH_USERS] != null) { data[ImageProcessor.AUTH_USERS] = requestBody[ImageProcessor.AUTH_USERS]; } if (DBProxy.Update(ImageProcessor.MYPHOTO_GALLERY_COLLECTION, filter.ToString(), data, false, MergeArrayHandling.Replace) != 1) { return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS)); } catch (Exception ex) { Logger.Error(ex.Message, ex); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } }
public JObject SendForgetpassOTP() { Logger.Debug("Calling SendForgetpassOTP"); JObject request = HttpProxy.GetRequestBody <JObject>(); if (request == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } Logger.Debug("Request body SendForgetpassOTP", request); UserModel requestUser = GetUserDataFromRequest(request); var recaptchaResponse = request[ModuleAppConsts.Field.GOOGLE_RECAPTCHA_RESPONSE_KEY].ToString(); var capchaChecked = SessionProvider.GetValue <bool>(USER_REGISTRATION_CAPCHA_VALIDATION_SESSION_KEY); if (capchaChecked && !GoogleCaptchaHelper.ValidateResponse(Logger, recaptchaResponse, AppSettingService.GetAppSettingData(ModuleAppConsts.Field.GOOGLE_RECAPTCHA_SECRECT_SETTING_KEY), AppSettingService.GetAppSettingData(ModuleAppConsts.Field.GOOGLE_RECAPTCHA_VALIDATE_URL_SETTING_KEY))) { Logger.Info("Captcha validate fail SendForgetpassOTP"); return(ResponseBuilder.CreateReponse(AppResponseCode._CAPTCHA_VALIDATION_FAIL)); } else { SessionProvider.SetValue <bool>(USER_REGISTRATION_CAPCHA_VALIDATION_SESSION_KEY, true); } if (IsUserExists(requestUser.user_id)) { string securityToken = CommonUtility.RandomString(10); if (requestUser.user_type == UserIDType.PhoneNumber.ToString() && OTPService.Send(requestUser.user_id, ModuleAppConsts.Field.FORGET_PASS_OTP_SMS_TEMPLATE, OTPType.Forgetpassword, securityToken)) { JObject dataResponse = new JObject(); dataResponse[CommonConst.CommonField.SECURITY_TOKEN] = securityToken; SessionProvider.SetValue <UserModel>(CommonConst.CommonValue.SIGN_UP_SESSION_USER_KEY, requestUser); return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS, null, dataResponse)); } else if (requestUser.user_type == UserIDType.Email.ToString() && OTPService.SendEmail(requestUser.user_id, ModuleAppConsts.Field.FORGET_PASS_OTP_EMAIL_TEMPLATE, AppSettingService.GetAppSettingData(ModuleAppConsts.Field.FORGET_PASS_OTP_EMAIL_SUBJECT), OTPType.Forgetpassword, securityToken)) { JObject dataResponse = new JObject(); dataResponse[CommonConst.CommonField.SECURITY_TOKEN] = securityToken; SessionProvider.SetValue <UserModel>(CommonConst.CommonValue.SIGN_UP_SESSION_USER_KEY, requestUser); return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS, null, dataResponse)); } else { return(ResponseBuilder.CreateReponse(AppResponseCode._OTP_SEND_ERROR)); } } else { return(ResponseBuilder.CreateReponse(AppResponseCode._USER_NOT_FOUND)); } }
public JObject ValidateOTP() { Logger.Debug("Calling ValidateOTP"); JObject request = HttpProxy.GetRequestBody <JObject>(); if (request == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } var otp = request[CommonConst.CommonField.OTP].ToString(); UserModel requestUser = GetUserDataFromRequest(request); var securityToken = request[CommonConst.CommonField.SECURITY_TOKEN].ToString(); if (!IsUserExists(requestUser.user_id)) { if (requestUser.user_type == UserIDType.PhoneNumber.ToString() && OTPService.Validate(requestUser.user_id, otp, OTPType.Signup, securityToken)) { UserModel tempUser = new UserModel() { user_id = requestUser.user_id, user_type = UserIDType.PhoneNumber.ToString() }; SessionProvider.SetValue(CommonConst.CommonValue.SIGN_UP_SESSION_USER_KEY, tempUser); return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS)); } else if (requestUser.user_type == UserIDType.Email.ToString() && OTPService.ValidateEmail(requestUser.user_id, otp, OTPType.Signup, securityToken)) { UserModel tempUser = new UserModel() { user_id = requestUser.user_id, user_type = UserIDType.Email.ToString() }; SessionProvider.SetValue(CommonConst.CommonValue.SIGN_UP_SESSION_USER_KEY, tempUser); return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS)); } else { Logger.Error("Error OTP validation fail"); return(ResponseBuilder.CreateReponse(AppResponseCode._OTP_VALIDATION_FAIL)); } } else { Logger.Info(string.Format("User Exits with this phone number {0}", requestUser.user_id)); return(ResponseBuilder.CreateReponse(AppResponseCode._USER_EXISTS)); } }
public JObject Create() { try { var user = SessionProvider.GetValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY); if (user == null) { return(ResponseBuilder.CreateReponse(CommonConst._401_UNAUTHORIZED)); } var requestBody = HttpProxy.GetRequestBody <JObject>(); if (requestBody == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } if (requestBody[ImageProcessor.DISPLAY_NAME] == null || requestBody[ImageProcessor.DESCRIPTION] == null || requestBody[ImageProcessor.AUTH_USERS] == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } JObject newAblum = new JObject(); newAblum[CommonConst.CommonField.DISPLAY_ID] = CommonUtility.GetNewID(); newAblum[CommonConst.CommonField.NAME] = string.Format("{0}-{1}", user.name, newAblum[CommonConst.CommonField.DISPLAY_ID].ToString()); newAblum[ImageProcessor.DISPLAY_NAME] = requestBody[ImageProcessor.DISPLAY_NAME].ToString(); newAblum[ImageProcessor.FILES_COUNT] = 0; newAblum[ImageProcessor.DESCRIPTION] = requestBody[ImageProcessor.DESCRIPTION].ToString(); newAblum[ImageProcessor.AUTH_USERS] = new JArray(); foreach (var e in (requestBody[ImageProcessor.AUTH_USERS] as JArray)) { (newAblum[ImageProcessor.AUTH_USERS] as JArray).Add(e.ToString()); } newAblum[ImageProcessor.OWNER] = user.user_id; DBProxy.Write(ImageProcessor.MYPHOTO_GALLERY_COLLECTION, newAblum); return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS, newAblum)); } catch (Exception ex) { Logger.Error(ex.Message, ex); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } }
public JObject Login() { Logger.Debug("Calling LoginController.Login"); JObject request = HttpProxy.GetRequestBody <JObject>(); if (request == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } var user_id = request[CommonConst.CommonField.USER_ID].ToString(); var password = request[CommonConst.CommonField.PASSWORD].ToString(); var recaptchaResponse = request[ModuleAppConsts.Field.GOOGLE_RECAPTCHA_RESPONSE_KEY].ToString(); if (!GoogleCaptchaHelper.ValidateResponse(Logger, recaptchaResponse, AppSettingService.GetAppSettingData(ModuleAppConsts.Field.GOOGLE_INVISIBLE_RECAPTCHA_SECRECT_SETTING_KEY), AppSettingService.GetAppSettingData(ModuleAppConsts.Field.GOOGLE_RECAPTCHA_VALIDATE_URL_SETTING_KEY))) { Logger.Info("Captcha validate fail"); return(ResponseBuilder.CreateReponse(AppResponseCode._CAPTCHA_VALIDATION_FAIL)); } if (Validate(user_id, password)) { JObject user = DBProxy.FirstOrDefault(CommonConst.Collection.USERS, CommonConst.CommonField.USER_ID, user_id); if (user == null) { return(ResponseBuilder.CreateReponse(CommonConst._401_UNAUTHORIZED, user)); } else { UserModel userModel = JObjectHelper.Deserialize <UserModel>(user); SessionProvider.SetValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY, userModel); return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS)); } } else { return(ResponseBuilder.CreateReponse(CommonConst._401_UNAUTHORIZED)); } }
public JObject ResetPassword() { try { Logger.Debug("Calling ResetPassword"); JObject request = HttpProxy.GetRequestBody <JObject>(); Logger.Debug("ResetPassword Request data", request); var redirect_url = HttpProxy.GetQueryString(CommonConst.CommonField.REDIRECT_URL_KEY); if (request == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } var otp = request[CommonConst.CommonField.OTP].ToString(); var requestUser = GetUserDataFromRequest(request); var forgetpasswordUser = SessionProvider.GetValue <UserModel>(CommonConst.CommonValue.SIGN_UP_SESSION_USER_KEY); if (forgetpasswordUser == null) { return(ResponseBuilder.CreateReponse(AppResponseCode._SESSION_USER_NOT_FOUND)); } if (forgetpasswordUser.user_id != requestUser.user_id) { return(ResponseBuilder.CreateReponse(AppResponseCode._SESSION_USER_DATA_MISMATCH)); } if (request[CommonConst.CommonField.PASSWORD].ToString() != request[CommonConst.CommonField.CONFIRM_PASSWORD].ToString()) { return(ResponseBuilder.CreateReponse(AppResponseCode._SESSION_USER_DATA_MISMATCH)); } var capchaChecked = SessionProvider.GetValue <bool>(USER_REGISTRATION_CAPCHA_VALIDATION_SESSION_KEY); if (!capchaChecked) { Logger.Info("Captcha validate fail"); return(ResponseBuilder.CreateReponse(AppResponseCode._CAPTCHA_VALIDATION_FAIL)); } bool OTPValidate = false; if (requestUser.user_type == UserIDType.PhoneNumber.ToString() && OTPService.Validate(requestUser.user_id, otp, OTPType.Forgetpassword, string.Empty)) { OTPValidate = true; } else if (requestUser.user_type == UserIDType.Email.ToString() && OTPService.ValidateEmail(requestUser.user_id, otp, OTPType.Forgetpassword, string.Empty)) { OTPValidate = true; } else { Logger.Error("Error OTP validation fail"); return(ResponseBuilder.CreateReponse(AppResponseCode._OTP_VALIDATION_FAIL)); } if (ResetPass(requestUser, request[CommonConst.CommonField.PASSWORD].ToString()) && OTPValidate) { var user = DBProxy.FirstOrDefault <UserModel>(CommonConst.Collection.USERS, CommonConst.CommonField.USER_ID, requestUser.user_id); var rurl = AppSettingService.GetAppSettingData(ModuleAppConsts.Field.FORGET_PASS_LENDING_PAGE_SETTING_KEY); JObject resonseData = new JObject(); if (string.IsNullOrEmpty(redirect_url)) { resonseData[CommonConst.CommonField.REDIRECT_URL_KEY] = rurl; } else { resonseData[CommonConst.CommonField.REDIRECT_URL_KEY] = string.Format("{0}?{1}={2}", rurl, CommonConst.CommonField.REDIRECT_URL_KEY, redirect_url); } return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS, null, resonseData)); } else { Logger.Error("Error while ResetPassword"); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } } catch (Exception ex) { Logger.Error(string.Format("Forgetpassword.ResetPassword error : {0}", ex.Message), ex); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } }
public JObject Update() { try { Logger.Debug(string.Format("Enter to UpdateContent.Update, SessionProvider:{0}", (SessionProvider == null ? "null" : "OK"))); UserModel user = SessionProvider.GetValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY); if (user == null) { Logger.Info(string.Format("Error in UpdateContent.Update: {0}", "user session is null")); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } JObject request = HttpProxy.GetRequestBody <JObject>(); if (request == null) { Logger.Info(string.Format("Error in UpdateContent.Update: {0}", "request object is null")); return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } string id = string.Empty; string data = string.Empty; string moduleName = string.Empty; if (request[CommonConst.CommonField.DISPLAY_ID] != null && request[CommonConst.CommonField.DATA] != null && request[CommonConst.CommonField.MODULE_NAME] != null ) { id = request[CommonConst.CommonField.DISPLAY_ID].ToString(); data = request[CommonConst.CommonField.DATA].ToString(); moduleName = request[CommonConst.CommonField.MODULE_NAME].ToString(); } if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(data) || string.IsNullOrEmpty(moduleName)) { Logger.Error(string.Format("Error in UpdateContent.Update: {0}", " id/data/moduleName empty")); return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } Logger.Debug("Get data for UpdateContent.Update", request); JObject updateFilter = new JObject(); updateFilter[CommonConst.CommonField.DISPLAY_ID] = id; if (moduleName != _contentUpdateModuleName) { var originalData = DBProxy.FirstOrDefault(CommonConst.Collection.STATIC_CONTECT, updateFilter.ToString()); if (originalData == null) { Logger.Error(string.Format("Error in UpdateContent.Update: {0}, collection{1}, filter {2}", "originalData is null", CommonConst.Collection.STATIC_CONTECT, updateFilter.ToString())); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } //bool isOverride = true; //bool.TryParse(originalData[CommonConst.CommonField.IS_OVERRIDE].ToString(), out isOverride); //if (isOverride) //{ // Logger.Error(string.Format("Error in UpdateContent.Update: {0}", "isOverride parameter is true in the oroginal data")); // return ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR); //} originalData[CommonConst.CommonField.IS_OVERRIDE] = true; originalData[CommonConst.CommonField.OVERRIDE_BY] = _contentUpdateModuleName; if (DBProxy.Update(CommonConst.Collection.STATIC_CONTECT, updateFilter.ToString(), originalData) != 1) { Logger.Error(string.Format("Error in UpdateContent.Update: {0}", "error updating originalData")); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } originalData[CommonConst.CommonField.DISPLAY_ID] = CommonUtility.GetNewID(); originalData[CommonConst.CommonField.IS_OVERRIDE] = false; originalData[CommonConst.CommonField.OVERRIDE_BY] = _contentUpdateModuleName; originalData[CommonConst.CommonField.DATA] = data; originalData[_contentHistory] = new JArray(); JObject filterFindExistingCustomization = new JObject(); filterFindExistingCustomization[CommonConst.CommonField.MODULE_NAME] = _contentUpdateModuleName; filterFindExistingCustomization[CommonConst.CommonField.FILE_PATH] = originalData[CommonConst.CommonField.FILE_PATH].ToString(); var existingData = DBProxy.FirstOrDefault(CommonConst.Collection.STATIC_CONTECT, filterFindExistingCustomization.ToString()); if (existingData == null) { if (!DBProxy.Write(CommonConst.Collection.STATIC_CONTECT, originalData)) { Logger.Error(string.Format("Error in UpdateContent.Update: {0}", "error adding new data")); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } } else { if (!UpdateCustomContentData(existingData, user, data, filterFindExistingCustomization)) { return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } } return(ReturnSuccess(originalData)); } else { var contentCustomData = DBProxy.FirstOrDefault(CommonConst.Collection.STATIC_CONTECT, updateFilter.ToString()); if (contentCustomData == null) { Logger.Error(string.Format("Error in UpdateContent.Update: {0}", "contentCustomData is null")); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } if (!UpdateCustomContentData(contentCustomData, user, data, updateFilter)) { return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } return(ReturnSuccess(contentCustomData)); } } catch (Exception ex) { Logger.Error(string.Format("Error in UpdateContent.Update: {0}", ex.Message), ex); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } }
public JObject CreateUser() { Logger.Debug("Calling CreateUser"); JObject request = HttpProxy.GetRequestBody <JObject>(); var redirect_url = HttpProxy.GetQueryString(CommonConst.CommonField.REDIRECT_URL_KEY); if (request == null) { return(ResponseBuilder.CreateReponse(CommonConst._400_BAD_REQUEST)); } var requestUser = GetUserDataFromRequest(request); if (IsOTPCheckEnable()) { var signUpUser = SessionProvider.GetValue <UserModel>(CommonConst.CommonValue.SIGN_UP_SESSION_USER_KEY); if (signUpUser == null) { return(ResponseBuilder.CreateReponse(AppResponseCode._SESSION_USER_NOT_FOUND)); } if (signUpUser.user_id != requestUser.user_id) { return(ResponseBuilder.CreateReponse(AppResponseCode._SESSION_USER_DATA_MISMATCH)); } } if (request[CommonConst.CommonField.PASSWORD].ToString() != request[CommonConst.CommonField.CONFIRM_PASSWORD].ToString()) { return(ResponseBuilder.CreateReponse(AppResponseCode._SESSION_USER_DATA_MISMATCH)); } var recaptchaResponse = request[ModuleAppConsts.Field.GOOGLE_RECAPTCHA_RESPONSE_KEY].ToString(); var capchaChecked = SessionProvider.GetValue <bool>(USER_REGISTRATION_CAPCHA_VALIDATION_SESSION_KEY); if (capchaChecked && !GoogleCaptchaHelper.ValidateResponse(Logger, recaptchaResponse, AppSettingService.GetAppSettingData(ModuleAppConsts.Field.GOOGLE_RECAPTCHA_SECRECT_SETTING_KEY), AppSettingService.GetAppSettingData(ModuleAppConsts.Field.GOOGLE_RECAPTCHA_VALIDATE_URL_SETTING_KEY))) { Logger.Info("Captcha validate fail"); return(ResponseBuilder.CreateReponse(AppResponseCode._CAPTCHA_VALIDATION_FAIL)); } else { SessionProvider.SetValue <bool>(USER_REGISTRATION_CAPCHA_VALIDATION_SESSION_KEY, true); } if (!IsUserExists(requestUser.user_id)) { if (CreateUser(requestUser, request[CommonConst.CommonField.PASSWORD].ToString())) { var user = DBProxy.FirstOrDefault <UserModel>(CommonConst.Collection.USERS, CommonConst.CommonField.USER_ID, requestUser.user_id); if (user == null) { Logger.Error(string.Format("User not found user_id : {0} ", requestUser.user_id)); return(ResponseBuilder.CreateReponse(AppResponseCode._USER_NOT_FOUND)); } else { SessionProvider.SetValue(CommonConst.CommonValue.SESSION_USER_KEY, user); var rurl = AppSettingService.GetAppSettingData(ModuleAppConsts.Field.SIGNUP_LENDING_PAGE_SETTING_KEY); JObject resonseData = new JObject(); if (string.IsNullOrEmpty(redirect_url)) { resonseData[CommonConst.CommonField.REDIRECT_URL_KEY] = rurl; } else { resonseData[CommonConst.CommonField.REDIRECT_URL_KEY] = string.Format("{0}?{1}={2}", rurl, CommonConst.CommonField.REDIRECT_URL_KEY, redirect_url); } return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS, null, resonseData)); } } else { Logger.Error("Error while addd new user"); return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR)); } } else { Logger.Info(string.Format("User Exits with this phone number {0}", requestUser.user_id)); return(ResponseBuilder.CreateReponse(AppResponseCode._USER_EXISTS)); } }