Use GraphQL for email available
This commit is contained in:
parent
63a1a24847
commit
24cccbf053
|
|
@ -3292,6 +3292,11 @@
|
||||||
"tslib": "^1.9.3"
|
"tslib": "^1.9.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"apollo-link-rest": {
|
||||||
|
"version": "0.7.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/apollo-link-rest/-/apollo-link-rest-0.7.3.tgz",
|
||||||
|
"integrity": "sha512-Cu60ZO/7de9preDsH3N3zHL40mrMfwgGbxPDdDEqRbes1Ms+DSRqBMv5yB641dSjSeZHKQW1ikQwc8GA8dBJKA=="
|
||||||
|
},
|
||||||
"apollo-utilities": {
|
"apollo-utilities": {
|
||||||
"version": "1.3.3",
|
"version": "1.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/apollo-utilities/-/apollo-utilities-1.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/apollo-utilities/-/apollo-utilities-1.3.3.tgz",
|
||||||
|
|
@ -9751,6 +9756,31 @@
|
||||||
"iterall": "^1.2.1"
|
"iterall": "^1.2.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"graphql-anywhere": {
|
||||||
|
"version": "4.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/graphql-anywhere/-/graphql-anywhere-4.2.6.tgz",
|
||||||
|
"integrity": "sha512-re4fqaii3l0fCsC3qFKQrmwffephI9rinrwXAy+4EnWip2YkGlV8wC4en42eW8KI2nlWBh9lkJPfR/5TZf/l1w==",
|
||||||
|
"requires": {
|
||||||
|
"apollo-utilities": "^1.3.3",
|
||||||
|
"ts-invariant": "^0.3.2",
|
||||||
|
"tslib": "^1.10.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ts-invariant": {
|
||||||
|
"version": "0.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.3.3.tgz",
|
||||||
|
"integrity": "sha512-UReOKsrJFGC9tUblgSRWo+BsVNbEd77Cl6WiV/XpMlkifXwNIJbknViCucHvVZkXSC/mcWeRnIGdY7uprcwvdQ==",
|
||||||
|
"requires": {
|
||||||
|
"tslib": "^1.9.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tslib": {
|
||||||
|
"version": "1.11.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz",
|
||||||
|
"integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"graphql-tag": {
|
"graphql-tag": {
|
||||||
"version": "2.10.1",
|
"version": "2.10.1",
|
||||||
"resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.10.1.tgz",
|
"resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.10.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
"apollo-link": "^1.2.13",
|
"apollo-link": "^1.2.13",
|
||||||
"apollo-link-error": "^1.1.12",
|
"apollo-link-error": "^1.1.12",
|
||||||
"apollo-link-http": "^1.5.16",
|
"apollo-link-http": "^1.5.16",
|
||||||
|
"apollo-link-rest": "^0.7.3",
|
||||||
"appolo": "^6.0.19",
|
"appolo": "^6.0.19",
|
||||||
"autoprefixer": "^7.1.2",
|
"autoprefixer": "^7.1.2",
|
||||||
"axios": "^0.18.0",
|
"axios": "^0.18.0",
|
||||||
|
|
@ -52,6 +53,7 @@
|
||||||
"file-loader": "^1.1.4",
|
"file-loader": "^1.1.4",
|
||||||
"friendly-errors-webpack-plugin": "^1.6.1",
|
"friendly-errors-webpack-plugin": "^1.6.1",
|
||||||
"graphql": "^0.13.2",
|
"graphql": "^0.13.2",
|
||||||
|
"graphql-anywhere": "^4.2.6",
|
||||||
"graphql-tag": "^2.10.1",
|
"graphql-tag": "^2.10.1",
|
||||||
"html-webpack-plugin": "^2.30.1",
|
"html-webpack-plugin": "^2.30.1",
|
||||||
"lodash": "^4.17.10",
|
"lodash": "^4.17.10",
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import {createHttpLink} from 'apollo-link-http'
|
||||||
import {onError} from 'apollo-link-error';
|
import {onError} from 'apollo-link-error';
|
||||||
import {ApolloClient} from 'apollo-client'
|
import {ApolloClient} from 'apollo-client'
|
||||||
import {ApolloLink, Observable} from 'apollo-link'
|
import {ApolloLink, Observable} from 'apollo-link'
|
||||||
|
import {RestLink} from 'apollo-link-rest';
|
||||||
import fetch from 'unfetch'
|
import fetch from 'unfetch'
|
||||||
import {typeDefs} from '@/graphql/typedefs';
|
import {typeDefs} from '@/graphql/typedefs';
|
||||||
import {resolvers} from '@/graphql/resolvers';
|
import {resolvers} from '@/graphql/resolvers';
|
||||||
|
|
@ -18,6 +19,21 @@ export default function (uri, networkErrorCallback) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const restLink = new RestLink(
|
||||||
|
{
|
||||||
|
uri: 'https://stage.hep-verlag.ch',
|
||||||
|
responseTransformer: async (response, typename) => response.text().then(text => {
|
||||||
|
if (typename === 'EmailAvailable') {
|
||||||
|
return {
|
||||||
|
__typename: typename,
|
||||||
|
isAvailable: text === 'true'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
); // todo: use env variable
|
||||||
const consoleLink = new ApolloLink((operation, forward) => {
|
const consoleLink = new ApolloLink((operation, forward) => {
|
||||||
// console.log(`starting request for ${operation.operationName}`);
|
// console.log(`starting request for ${operation.operationName}`);
|
||||||
|
|
||||||
|
|
@ -64,7 +80,7 @@ export default function (uri, networkErrorCallback) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const composedLink = ApolloLink.from([createOmitTypenameLink, consoleLink, errorLink, httpLink]);
|
const composedLink = ApolloLink.from([createOmitTypenameLink, consoleLink, errorLink, restLink, httpLink]);
|
||||||
|
|
||||||
const cache = new InMemoryCache({
|
const cache = new InMemoryCache({
|
||||||
dataIdFromObject: obj => {
|
dataIdFromObject: obj => {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
query IsEmailAvailable($input: String!) {
|
||||||
|
isEmailAvailable(input: $input) @rest(type: "EmailAvailable", path: "/rest/deutsch/V1/customers/isEmailAvailable", method: "POST") {
|
||||||
|
isAvailable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
query IsEmailAvailable($input: String!) {
|
||||||
|
isEmailAvailable(input: $input) @rest(type: "isEmailAvailable", path: "/rest/deutsch/V1/customers/isEmailAvailable", methods: "POST") {
|
||||||
|
isAvailable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,10 +9,3 @@ export function register(registrationData) {
|
||||||
export function login(username, password) {
|
export function login(username, password) {
|
||||||
return axios.post(`${hepBaseUrl}/rest/deutsch/V1/integration/customer/token`, {username, password});
|
return axios.post(`${hepBaseUrl}/rest/deutsch/V1/integration/customer/token`, {username, password});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function emailExists(email) {
|
|
||||||
return axios.post(`${hepBaseUrl}/rest/deutsch/V1/customers/isEmailAvailable`, {
|
|
||||||
customerEmail: email,
|
|
||||||
websiteId: 1
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<h1 class="forgot-password__title public-page__title" data-cy="forgot-password">Passwort vergessen?</h1>
|
<h1 class="forgot-password__title public-page__title" data-cy="forgot-password">Passwort vergessen?</h1>
|
||||||
</header>
|
</header>
|
||||||
<section class="forgot-password__section forgot-password__text">
|
<section class="forgot-password__section forgot-password__text">
|
||||||
<p class="forgot-info">Ihr Benutzerkonto wird durch den Hep Verlag verwaltet und deshalb können Sie das Passwort ausschliesslicht auf
|
<p class="forgot-info">Ihr Benutzerkonto wird durch den Hep Verlag verwaltet und deshalb können Sie das Passwort ausschliesslich auf
|
||||||
<a class="noserif-link" href="https://www.hep-verlag.ch">www.hep-verlag.ch</a> verwaltet werden.</p>
|
<a class="noserif-link" href="https://www.hep-verlag.ch">www.hep-verlag.ch</a> verwaltet werden.</p>
|
||||||
<p class="forgot-info">Melden Sie sich mit der gleichen E-Mail-Adresse und dem gleichen </p>
|
<p class="forgot-info">Melden Sie sich mit der gleichen E-Mail-Adresse und dem gleichen </p>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_variables.scss";
|
@import "@/styles/_variables.scss";
|
||||||
@import "@/styles/_mixins.scss";
|
@import "@/styles/_mixins.scss";
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
import {emailExists} from '../hep-client/index';
|
import {emailExists} from '../hep-client/index';
|
||||||
import HELLO_EMAIL_MUTATION from '@/graphql/gql/local/mutations/helloEmail.gql';
|
import HELLO_EMAIL_MUTATION from '@/graphql/gql/local/mutations/helloEmail.gql';
|
||||||
|
import IS_EMAIL_AVAILABLE_QUERY from '@/graphql/gql/rest/isEmailAvailableQuery.gql';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {},
|
components: {},
|
||||||
|
|
@ -44,22 +45,29 @@ export default {
|
||||||
this.$validator.validate().then(result => {
|
this.$validator.validate().then(result => {
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
if (result) {
|
if (result) {
|
||||||
emailExists(this.email).then((response) => {
|
this.$apollo.query({
|
||||||
let redirectRouteName = 'login';
|
query: IS_EMAIL_AVAILABLE_QUERY,
|
||||||
|
variables: {
|
||||||
if (response.data) {
|
input: {
|
||||||
redirectRouteName = 'registration';
|
customerEmail: this.email,
|
||||||
}
|
websiteId: 1
|
||||||
|
|
||||||
this.$apollo.mutate({
|
|
||||||
mutation: HELLO_EMAIL_MUTATION,
|
|
||||||
variables: {
|
|
||||||
helloEmail: this.email
|
|
||||||
}
|
}
|
||||||
}).then(() => this.$router.push({name: redirectRouteName, query: this.$route.query}));
|
}
|
||||||
|
}).then(({data}) => {
|
||||||
|
let redirectRouteName = 'login';
|
||||||
|
if (data.isEmailAvailable.isAvailable) {
|
||||||
|
redirectRouteName = 'registration';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: HELLO_EMAIL_MUTATION,
|
||||||
|
variables: {
|
||||||
|
helloEmail: this.email
|
||||||
|
}
|
||||||
|
}).then(() => this.$router.push({name: redirectRouteName, query: this.$route.query}));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.registrationError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie es nochmals.';
|
this.registrationError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie es nochmals.';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue