Skip to content

Commit

Permalink
chore(docs): update demo site to always supply v3 token
Browse files Browse the repository at this point in the history
  • Loading branch information
DethAriel committed Sep 14, 2020
1 parent 79fc85b commit 002e29e
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 28 deletions.
3 changes: 2 additions & 1 deletion demo/v-all/src/app/examples/basic/basic-demo.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';

import { RECAPTCHA_LANGUAGE, RecaptchaModule } from 'ng-recaptcha';
import { RecaptchaModule, RECAPTCHA_LANGUAGE, RECAPTCHA_V3_SITE_KEY } from 'ng-recaptcha';

import { parseLangFromHref } from '../../parse-lang-from-href';
import { BasicDemoComponent } from './basic-demo.component';
Expand All @@ -24,6 +24,7 @@ const routes: Routes = [
CommonModule,
],
providers: [
{ provide: RECAPTCHA_V3_SITE_KEY, useValue: '6LeGCZAUAAAAADuhzcuvSB-lYDsxJBl9HUWtZkUM' },
{ provide: RECAPTCHA_LANGUAGE, useValue: parseLangFromHref() },
],
})
Expand Down
3 changes: 2 additions & 1 deletion demo/v-all/src/app/examples/forms/forms-demo.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';

import { RecaptchaFormsModule, RecaptchaModule, RECAPTCHA_LANGUAGE } from 'ng-recaptcha';
import { RecaptchaFormsModule, RecaptchaModule, RECAPTCHA_LANGUAGE, RECAPTCHA_V3_SITE_KEY } from 'ng-recaptcha';

import { parseLangFromHref } from '../../parse-lang-from-href';
import { FormsDemoComponent } from './forms-demo.component';
Expand All @@ -27,6 +27,7 @@ const routes: Routes = [
CommonModule,
],
providers: [
{ provide: RECAPTCHA_V3_SITE_KEY, useValue: '6LeGCZAUAAAAADuhzcuvSB-lYDsxJBl9HUWtZkUM' },
{ provide: RECAPTCHA_LANGUAGE, useValue: parseLangFromHref() },
],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
RecaptchaModule,
RecaptchaSettings,
RECAPTCHA_LANGUAGE,
RECAPTCHA_V3_SITE_KEY,
} from 'ng-recaptcha';

import { parseLangFromHref } from '../../parse-lang-from-href';
Expand Down Expand Up @@ -38,6 +39,7 @@ const routes: Routes = [
useValue: globalSettings,
},
{ provide: RECAPTCHA_LANGUAGE, useValue: parseLangFromHref() },
{ provide: RECAPTCHA_V3_SITE_KEY, useValue: '6LeGCZAUAAAAADuhzcuvSB-lYDsxJBl9HUWtZkUM' },
],
})
export class DemoModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';

import { RecaptchaModule, RECAPTCHA_LANGUAGE } from 'ng-recaptcha';
import { RecaptchaModule, RECAPTCHA_LANGUAGE, RECAPTCHA_V3_SITE_KEY } from 'ng-recaptcha';

import { parseLangFromHref } from '../../parse-lang-from-href';
import { InvisibleDemoComponent } from './invisible-demo.component';
Expand All @@ -25,6 +25,7 @@ const routes: Routes = [
],
providers: [
{ provide: RECAPTCHA_LANGUAGE, useValue: parseLangFromHref() },
{ provide: RECAPTCHA_V3_SITE_KEY, useValue: '6LeGCZAUAAAAADuhzcuvSB-lYDsxJBl9HUWtZkUM' },
],
})
export class DemoModule { }
18 changes: 11 additions & 7 deletions demo/v-all/src/app/examples/preload-api/preload-api-demo.module-de
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, NgModule } from '@angular/core';
import { Injectable, NgModule, Optional, Inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';

import { BehaviorSubject, Observable } from 'rxjs';

import { RecaptchaLoaderService, RecaptchaModule, RECAPTCHA_LANGUAGE } from 'ng-recaptcha';
import { RecaptchaLoaderService, RecaptchaModule, RECAPTCHA_LANGUAGE, RECAPTCHA_V3_SITE_KEY } from 'ng-recaptcha';

import { PreloadApiDemoComponent } from './preload-api-demo.component';
import { settings } from './preload-api-demo.data';
Expand All @@ -13,14 +13,18 @@ import { settings } from './preload-api-demo.data';
export class PreloadedRecaptchaAPIService {
public ready: Observable<ReCaptchaV2.ReCaptcha>;

constructor() {
constructor(
@Optional() @Inject(RECAPTCHA_V3_SITE_KEY) v3SiteKey?: string,
) {
const readySubject = new BehaviorSubject<ReCaptchaV2.ReCaptcha>(null);
this.ready = readySubject.asObservable();

const recaptchaScript = document.createElement('script');
recaptchaScript.src = 'https://www.google.com/recaptcha/api.js?render=explicit';
document.head.appendChild(recaptchaScript);

if (typeof grecaptcha === 'undefined') {
const recaptchaScript = document.createElement('script');
const renderMode = v3SiteKey || 'explicit';
recaptchaScript.src = `https://www.google.com/recaptcha/api.js?render=${v3SiteKey}`;
document.head.appendChild(recaptchaScript);
}

const interval = setInterval(() => {
if (typeof grecaptcha === 'undefined' || !(grecaptcha.render instanceof Function)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, NgModule } from '@angular/core';
import { Injectable, NgModule, Optional, Inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';

import { BehaviorSubject, Observable } from 'rxjs';

import { RecaptchaLoaderService, RecaptchaModule } from 'ng-recaptcha';
import { RecaptchaLoaderService, RecaptchaModule, RECAPTCHA_V3_SITE_KEY } from 'ng-recaptcha';

import { PreloadApiDemoComponent } from './preload-api-demo.component';
import { settings } from './preload-api-demo.data';
Expand All @@ -13,14 +13,18 @@ import { settings } from './preload-api-demo.data';
export class PreloadedRecaptchaAPIService {
public ready: Observable<ReCaptchaV2.ReCaptcha>;

constructor() {
constructor(
@Optional() @Inject(RECAPTCHA_V3_SITE_KEY) v3SiteKey?: string,
) {
const readySubject = new BehaviorSubject<ReCaptchaV2.ReCaptcha>(null);
this.ready = readySubject.asObservable();

const recaptchaScript = document.createElement('script');
recaptchaScript.src = 'https://www.google.com/recaptcha/api.js?render=explicit';
document.head.appendChild(recaptchaScript);

if (typeof grecaptcha === 'undefined') {
const recaptchaScript = document.createElement('script');
const renderMode = v3SiteKey || 'explicit';
recaptchaScript.src = `https://www.google.com/recaptcha/api.js?render=${v3SiteKey}`;
document.head.appendChild(recaptchaScript);
}

const interval = setInterval(() => {
if (typeof grecaptcha === 'undefined' || !(grecaptcha.render instanceof Function)) {
Expand Down
18 changes: 11 additions & 7 deletions demo/v-all/src/app/examples/preload-api/preload-api-demo.module-fr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, NgModule } from '@angular/core';
import { Injectable, NgModule, Optional, Inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';

import { BehaviorSubject, Observable } from 'rxjs';

import { RecaptchaLoaderService, RecaptchaModule, RECAPTCHA_LANGUAGE } from 'ng-recaptcha';
import { RecaptchaLoaderService, RecaptchaModule, RECAPTCHA_LANGUAGE, RECAPTCHA_V3_SITE_KEY } from 'ng-recaptcha';

import { PreloadApiDemoComponent } from './preload-api-demo.component';
import { settings } from './preload-api-demo.data';
Expand All @@ -13,14 +13,18 @@ import { settings } from './preload-api-demo.data';
export class PreloadedRecaptchaAPIService {
public ready: Observable<ReCaptchaV2.ReCaptcha>;

constructor() {
constructor(
@Optional() @Inject(RECAPTCHA_V3_SITE_KEY) v3SiteKey?: string,
) {
const readySubject = new BehaviorSubject<ReCaptchaV2.ReCaptcha>(null);
this.ready = readySubject.asObservable();

const recaptchaScript = document.createElement('script');
recaptchaScript.src = 'https://www.google.com/recaptcha/api.js?render=explicit';
document.head.appendChild(recaptchaScript);

if (typeof grecaptcha === 'undefined') {
const recaptchaScript = document.createElement('script');
const renderMode = v3SiteKey || 'explicit';
recaptchaScript.src = `https://www.google.com/recaptcha/api.js?render=${v3SiteKey}`;
document.head.appendChild(recaptchaScript);
}

const interval = setInterval(() => {
if (typeof grecaptcha === 'undefined' || !(grecaptcha.render instanceof Function)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, NgModule } from '@angular/core';
import { Injectable, NgModule, Optional, Inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';

import { BehaviorSubject, Observable } from 'rxjs';

import { RecaptchaLoaderService, RecaptchaModule, RECAPTCHA_LANGUAGE } from 'ng-recaptcha';
import { RecaptchaLoaderService, RecaptchaModule, RECAPTCHA_LANGUAGE, RECAPTCHA_V3_SITE_KEY } from 'ng-recaptcha';

import { parseLangFromHref } from '../../parse-lang-from-href';
import { PreloadApiDemoComponent } from './preload-api-demo.component';
Expand All @@ -14,13 +14,16 @@ import { settings } from './preload-api-demo.data';
export class PreloadedRecaptchaAPIService {
public ready: Observable<ReCaptchaV2.ReCaptcha>;

constructor() {
constructor(
@Optional() @Inject(RECAPTCHA_V3_SITE_KEY) v3SiteKey?: string,
) {
const readySubject = new BehaviorSubject<ReCaptchaV2.ReCaptcha>(null);
this.ready = readySubject.asObservable();

if (typeof grecaptcha === 'undefined') {
const recaptchaScript = document.createElement('script');
recaptchaScript.src = 'https://www.google.com/recaptcha/api.js?render=explicit';
const renderMode = v3SiteKey || 'explicit';
recaptchaScript.src = `https://www.google.com/recaptcha/api.js?render=${v3SiteKey}`;
document.head.appendChild(recaptchaScript);
}

Expand Down Expand Up @@ -58,6 +61,7 @@ const routes: Routes = [
useValue: service,
},
{ provide: RECAPTCHA_LANGUAGE, useValue: parseLangFromHref() },
{ provide: RECAPTCHA_V3_SITE_KEY, useValue: '6LeGCZAUAAAAADuhzcuvSB-lYDsxJBl9HUWtZkUM' },
],
})
export class DemoModule { }

0 comments on commit 002e29e

Please sign in to comment.