public async Task IsReCaptchaSucceed_passDevCapcha_returnsTrue() { var result = await reCaptchaService.IsReCaptchaSucceed( "test", config.ReCaptchaSecret, "localhost"); Assert.IsTrue(result); }
/// <summary> /// Checks ReCaptcha and all payload properties. /// </summary> /// <returns> /// /// 460 - when invitation key is invalid (Constants.INV_KEY_LENGTH), /// 461 - when invitation key was not found in database, /// 462 - when invitation key was used by another user, /// /// 463 - when new user object properties are invalid, /// 464 - when given email from new user object is already used, /// 465 - when given login from new user object is already used, /// /// 499 - when reCaptcha validation failed, /// </returns> private async Task <DataOrStatusCodeDto <IUser> > CheckReCaptchaValidateKeyAndUser(UserRegisterDto payload, string host) { var reCaptchaSucceed = await _reCaptchaService.IsReCaptchaSucceed(payload.ReCaptchaToken, _config.ReCaptchaSecret, host); if (reCaptchaSucceed) { var keyResult = await _invitationKeyService.ValidateAndReturnObject(payload.InvitationKey); if (keyResult.Succeed) { payload.User.TrimProperties(); return(_userService.ValidateBeforeRegister(payload.User)); } else { return(keyResult.ToFailType <IUser>()); } } else { return(new DataOrStatusCodeDto <IUser>(499, "ReCaptcha failed.")); } }