Remove unused code

This commit is contained in:
Christian Cueni 2021-05-12 13:48:47 +02:00
parent 8ac5ab67e9
commit 8db122c436
7 changed files with 1 additions and 772 deletions

View File

@ -1,6 +0,0 @@
mutation Registration($input: RegistrationInput!) {
registration(input: $input) {
success
message
}
}

View File

@ -1,96 +0,0 @@
<template>
<div class="emailconfirmation public-page">
<h1 class="emailconfirmation__title public-page__title">Überprüfung der E-Mail Adresse</h1>
<p v-if="loading">Der Verifikationscode wird überprüft.</p>
<p
data-cy="code-ok-msg"
v-if="showOkMessage">Der Verifikationscode ist gültig. Sie werden weitergeleitet.</p>
<p
data-cy="code-nok-msg"
v-if="showErrorMessage">{{ errorMessage }}</p>
</div>
</template>
<script>
import REGISTRATION_MUTATION from '@/graphql/gql/mutations/registration.gql';
export default {
data() {
return {
loading: true,
keyValid: false,
errorMessage: ''
};
},
computed: {
showOkMessage() {
return !this.loading && this.keyValid;
},
showErrorMessage() {
return !this.loading && !this.keyValid;
}
},
mounted() {
this.$apollo.mutate({
mutation: REGISTRATION_MUTATION,
client: 'publicClient',
variables: {
input: {
confirmationKey: this.$route.query.confirmation,
userId: this.$route.query.id
}
},
fetchPolicy: 'no-cache'
}).then(({data}) => {
this.loading = false;
if (data.registration.success) {
this.keyValid = true;
if (data.registration.message === 'no_valid_license') {
this.$router.push({name: 'licenseActivation'});
} else {
this.$router.push('/');
}
} else {
switch (data.registration.message) {
case 'invalid_key':
this.errorMessage = 'Der angegebene Verifizierungscode ist ungültig oder abgelaufen.';
break;
case 'no_valid_license':
this.$router.push({name: 'licenseActivation'});
break;
default:
this.errorMessage = 'Ein Fehler ist aufgetreten. Bitte kontaktieren Sie den Administrator.';
}
}
})
.catch(() => {
this.errorMessage = 'Ein Fehler ist aufgetreten. Bitte kontaktieren Sie den Administrator.';
});
},
};
</script>
<style scoped lang="scss">
@import "@/styles/_variables.scss";
@import "@/styles/_mixins.scss";
.text-link {
font-family: $sans-serif-font-family;
color: $color-brand;
}
.actions {
&__reset {
display: inline-block;
margin-left: $large-spacing;
}
}
</style>

View File

@ -1,196 +0,0 @@
<template>
<div class="login public-page">
<header class="info-header">
<p class="info-header__text small-emph">Super, wir haben für <span
class="info-header__emph">{{ helloEmail.email }}</span> ein hep-Konto gefunden.</p>
<h1
class="login__title public-page__title"
data-cy="login-title">Bitte geben Sie das passende Passwort ein</h1>
</header>
<form
class="login__form login-form"
novalidate
@submit.prevent="validateBeforeSubmit">
<div class="change-form__field skillboxform-input">
<label
for="password"
class="skillboxform-input__label">Passwort</label>
<input
v-model="password"
v-validate="'required'"
:class="{ 'skillboxform-input__input--error': errors.has('password') }"
name="password"
type="password"
data-vv-as="Passwort"
class="change-form__new skillbox-input skillboxform-input__input"
autocomplete="off"
data-cy="password-input"
tabindex="0"
id="password"
>
<small
:key="error"
class="skillboxform-input__error"
data-cy="password-errors"
v-for="error in passwordErrors"
>{{ error }}</small>
</div>
<div class="actions">
<loading-button
:loading="loading"
class="actions__submit"
data-cy="login-button"
label="Anmelden"
/>
<router-link
:to="{name: 'hello'}"
tag="button"
class="button button--big actions__submit back-button">Abbrechen
</router-link>
<router-link
:to="{name: 'forgotPassword'}"
class="actions__reset text-link">Passwort vergessen?</router-link>
</div>
</form>
</div>
</template>
<script>
import HELLO_EMAIL from '@/graphql/gql/local/helloEmail.gql';
import LOGIN_MUTATION from '@/graphql/gql/mutations/login.gql';
import LoadingButton from '@/components/LoadingButton';
export default {
components: {LoadingButton},
data() {
return {
password: '',
passwordErrors: [],
submitted: false,
loading: false
};
},
methods: {
validateBeforeSubmit() {
// this.$validator.validate().then(result => {
// this.submitted = true;
// if (result) {
// this.loading = true;
// login(this.helloEmail.email, this.password)
// .then((response) => {
// this.loading = false;
// if (response.status === 200) {
// this.mySkillboxLogin(response.data);
// } else {
// this.passwordErrors = ['Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.'];
// }
// })
// .catch((error) => {
// this.loading = false;
// if (error.response.data.message && error.response.data.message === 'Sie haben sich nicht korrekt eingeloggt oder Ihr Konto ist vor\u00fcbergehend deaktiviert.') {
// this.passwordErrors = ['Die von Ihnen eingegebene E-Mail-Adresse und das Passwort passen nicht zusammen.'];
// } else {
// this.passwordErrors = ['Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.'];
// }
// });
// }
// });
},
mySkillboxLogin(token) {
const that = this;
this.$apollo.mutate({
client: 'publicClient',
mutation: LOGIN_MUTATION,
variables: {
input: {
tokenInput: token
}
},
update(
store,
{
data: {
login
}
}
) {
try {
if (login.success) {
if (login.message === 'no_valid_license') {
that.$router.push({name: 'licenseActivation'});
} else {
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/';
that.$router.push(redirectUrl);
}
}
} catch (e) {
that.passwordErrors = ['Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.'];
}
}
})
.catch(errors => {
const firstError = errors.graphQLErrors[0];
switch (firstError.message) {
case 'invalid_credentials':
that.passwordErrors = ['Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.'];
break;
case 'email_not_verified':
that.passwordErrors = ['Bitte verifiziere zuerst deine E-Mail.'];
break;
case 'no_valid_license':
this.$router.push({name: 'licenseActivation'});
break;
}
});
},
resetForm() {
this.password = '';
this.submitted = false;
this.$validator.reset();
},
},
apollo: {
helloEmail: {
query: HELLO_EMAIL,
result({data: {helloEmail}}) {
if (helloEmail.email === '') {
this.$router.push({name: 'hello'});
}
}
},
},
};
</script>
<style scoped lang="scss">
@import "@/styles/_variables.scss";
@import "@/styles/_mixins.scss";
.text-link {
font-family: $sans-serif-font-family;
color: $color-brand;
}
.actions {
display: flex;
&__reset {
display: inline-block;
margin-left: auto;
line-height: 19px;;
padding: $small-spacing;
}
}
.back-button {
//font-size: 1rem;
line-height: normal;
margin-left: $medium-spacing;
}
</style>

View File

@ -1,422 +0,0 @@
<template>
<div class="registration public-page">
<header class="info-header">
<p class="info-header__text small-emph">Für <span class="info-header__emph">{{ helloEmail }}</span> haben wir kein
Hep Konto gefunden.</p>
<h1
class="registration__title public-page__title"
data-cy="registration-title">Damit Sie {{ pageTitle }} verwenden können, müssen Sie ein Konto erstellen.</h1>
</header>
<form
class="registration__form registration-form"
novalidate
@submit.prevent="validateBeforeSubmit">
<div class="registration-form__field skillboxform-input">
<div class="registration-form__field skillboxform-input">
<label
for="prefix"
class="skillboxform-input__label">Anrede</label>
<select
v-model="prefix"
v-validate="'required'"
:class="{ 'skillboxform-input__input--error': errors.has('prefix') }"
name="prefix"
data-vv-as="Prefix"
class="change-form__prefix skillbox-input skillboxform-input__input skillbox-dropdown"
autocomplete="off"
data-cy="prefix-selection"
id="prefix"
>
<option
value="Herr"
selected>Herr
</option>
<option value="Frau">Frau</option>
</select>
</div>
<label
for="firstname"
class="skillboxform-input__label">Vorname</label>
<input
v-model="firstname"
v-validate="'required'"
:class="{ 'skillboxform-input__input--error': errors.has('firstname') }"
name="firstname"
type="text"
data-vv-as="Vorname"
class="change-form__firstname skillbox-input skillboxform-input__input"
autocomplete="off"
data-cy="firstname-input"
id="firstname"
>
<small
class="skillboxform-input__error"
data-cy="firstname-local-errors"
v-if="errors.has('firstname') && submitted"
>{{ errors.first('firstname') }}</small>
<small
:key="error"
class="skillboxform-input__error"
data-cy="firstname-remote-errors"
v-for="error in firstnameErrors"
>{{ error }}</small>
</div>
<div class="change-form__field skillboxform-input">
<label
for="lastname"
class="skillboxform-input__label">Nachname</label>
<input
v-model="lastname"
v-validate="'required'"
:class="{ 'skillboxform-input__input--error': errors.has('lastname') }"
name="lastname"
type="text"
data-vv-as="Nachname"
class="change-form__new skillbox-input skillboxform-input__input"
autocomplete="off"
data-cy="lastname-input"
id="lastname"
>
<small
class="skillboxform-input__error"
data-cy="lastname-local-errors"
v-if="errors.has('lastname') && submitted"
>{{ errors.first('lastname') }}</small>
<small
:key="error"
class="skillboxform-input__error"
data-cy="lastname-remote-errors"
v-for="error in lastnameErrors"
>{{ error }}</small>
</div>
<div class="change-form__field skillboxform-input">
<label
for="street"
class="skillboxform-input__label">Strasse</label>
<input
v-model="street"
v-validate="'required'"
:class="{ 'skillboxform-input__input--error': errors.has('street') }"
name="street"
type="text"
data-vv-as="Strasse"
class="change-form__new skillbox-input skillboxform-input__input"
autocomplete="off"
data-cy="street-input"
id="street"
>
<small
class="skillboxform-input__error"
data-cy="street-local-errors"
v-if="errors.has('street') && submitted"
>{{ errors.first('street') }}</small>
<small
:key="error"
class="skillboxform-input__error"
data-cy="street-remote-errors"
v-for="error in streetErrors"
>{{ error }}</small>
</div>
<div class="change-form__field skillboxform-input">
<label
for="city"
class="skillboxform-input__label">Ort</label>
<input
v-model="city"
v-validate="'required'"
:class="{ 'skillboxform-input__input--error': errors.has('city') }"
name="city"
type="text"
data-vv-as="Ort"
class="change-form__new skillbox-input skillboxform-input__input"
autocomplete="off"
data-cy="city-input"
id="city"
>
<small
class="skillboxform-input__error"
data-cy="city-local-errors"
v-if="errors.has('city') && submitted"
>{{ errors.first('city') }}</small>
<small
:key="error"
class="skillboxform-input__error"
data-cy="city-remote-errors"
v-for="error in cityErrors"
>{{ error }}</small>
</div>
<div class="change-form__field skillboxform-input">
<label
for="postcode"
class="skillboxform-input__label">Postleitzahl</label>
<input
v-model="postcode"
v-validate="'required'"
:class="{ 'skillboxform-input__input--error': errors.has('postcode') }"
name="postcode"
type="text"
data-vv-as="Postleitzahl"
class="change-form__new skillbox-input skillboxform-input__input"
autocomplete="off"
data-cy="postcode-input"
id="postcode"
>
<small
class="skillboxform-input__error"
data-cy="postcode-local-errors"
v-if="errors.has('postcode') && submitted"
>{{ errors.first('postcode') }}</small>
<small
:key="error"
class="skillboxform-input__error"
data-cy="postcode-remote-errors"
v-for="error in postcodeErrors"
>{{ error }}</small>
</div>
<div class="change-form__field skillboxform-input">
<label
for="password"
class="skillboxform-input__label">Passwort</label>
<input
v-model="password"
v-validate="'required|strongPassword'"
:class="{ 'skillboxform-input__input--error': errors.has('password') && submitted }"
name="password"
type="text"
data-vv-as="Passwort"
class="change-form__new skillbox-input skillboxform-input__input"
autocomplete="off"
data-cy="password-input"
id="password"
ref="password"
>
<small
class="skillboxform-input__error"
data-cy="password-local-errors"
v-if="errors.has('password') && submitted"
>{{ errors.first('password') }}</small>
</div>
<div class="change-form__field skillboxform-input">
<label
for="password2"
class="skillboxform-input__label">Passwort wiederholen</label>
<input
v-model="passwordConfirmation"
v-validate="'required|confirmed:password'"
:class="{ 'skillboxform-input__input--error': errors.has('password-confirmation') && submitted }"
name="password-confirmation"
type="text"
data-vv-as="Passwort wiederholen"
class="change-form__new skillbox-input skillboxform-input__input"
autocomplete="off"
data-cy="passwordConfirmation-input"
id="password-confirmation"
>
<small
class="skillboxform-input__error"
data-cy="passwordConfirmation-local-errors"
v-if="errors.has('password-confirmation') && submitted"
>{{ errors.first('password-confirmation') }}</small>
</div>
<div class="change-form__field skillboxform-input">
<checkbox
v-model="acceptedTerms"
:checked="acceptedTerms"
v-validate="'required:true'"
:class="{ 'skillboxform-input__input--error': errors.has('accepted-terms') && submitted}"
name="accepted-terms"
class="skillboxform-input__checkbox"
data-cy="acceptedTerms-input"
id="accepted-terms"
>
<span>Hiermit akzeptiere ich die <a
href="https://www.hep-verlag.ch/agb"
target="_blank"
class="hep-link">AGB</a> und
<a
href="https://www.hep-verlag.ch/datenschutz"
target="_blank"
class="hep-link">Datenschutzbestimmungen</a></span>
</checkbox>
<small
class="skillboxform-input__error"
data-cy="acceptedTerms-local-errors"
v-if="errors.has('accepted-terms') && submitted"
>Sie müssen hier zustimmen, damit Sie sich registrieren können.</small>
</div>
<div class="skillboxform-input">
<small
class="skillboxform-input__error"
data-cy="registration-error"
v-if="registrationError">{{ registrationError }}</small>
</div>
<div class="actions">
<loading-button
:loading="loading"
class="actions__submit"
label="Konto erstellen"
data-cy="register-button"
/>
</div>
</form>
</div>
</template>
<script>
import HELLO_EMAIL from '@/graphql/gql/local/helloEmail.gql';
import Checkbox from '@/components/ui/Checkbox';
import LoadingButton from '@/components/LoadingButton';
import pageTitleMixin from '@/mixins/page-title';
function initialData() {
return {
prefix: 'Herr',
lastname: '',
firstname: '',
password: '',
passwordConfirmation: '',
street: '',
postcode: '',
city: '',
acceptedTerms: false,
firstnameErrors: '',
lastnameErrors: '',
emailErrors: '',
passwordsErrors: [],
passwordErrors: [],
streetErrors: [],
cityErrors: [],
postcodeErrors: [],
registrationError: '',
acceptedTermsError: [],
submitted: false,
};
}
export default {
mixins: [pageTitleMixin],
components: {
LoadingButton,
Checkbox
},
data() {
return Object.assign(
{
helloEmail: '',
loading: false,
},
initialData()
);
},
methods: {
validateBeforeSubmit() {
this.$validator.validate().then(result => {
this.submitted = true;
if (result) {
this.loading = true;
// const registrationData = {
// customer: {
// prefix: this.prefix,
// email: this.helloEmail,
// firstname: this.firstname,
// lastname: this.lastname,
// gender: this.prefix === 'Herr' ? 1 : 2,
// addresses: [{
// street: [this.street],
// postcode: this.postcode,
// city: this.city,
// country_id: 'CH',
// firstname: this.firstname,
// lastname: this.lastname,
// prefix: this.prefix,
// default_shipping: true,
// default_billing: true
// }]
// },
// password: this.password,
// accepted_terms: this.acceptedTerms
// };
// register(registrationData).then((response) => {
// this.loading = false;
// if (response.data.id && response.data.id > 0) {
// this.$router.push({name: 'checkEmail'});
// }
// })
// .catch((error) => {
// this.loading = false;
// console.warn(error);
// if (error.response.data.message) {
// switch (error.response.data.message) {
// case 'Ein Kunde mit der gleichen E-Mail-Adresse existiert bereits in einer zugeordneten Website.':
// this.emailErrors = ['Die angegebene E-Mail ist bereits registriert.'];
// break;
// case 'Sie müssen hier zustimmen, damit Sie sich registrieren können.':
// this.acceptedTermsError = ['Sie müssen hier zustimmen, damit Sie sich registrieren können.'];
// break;
// default:
// this.registrationError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
// }
// } else {
// this.registrationError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
// }
// });
}
});
},
resetForm() {
Object.assign(this.$data, initialData());
this.$validator.reset();
}
},
apollo: {
helloEmail: {
query: HELLO_EMAIL,
result({data}) {
if (data.helloEmail && data.helloEmail.email === '') {
this.$router.push({name: 'hello'});
}
},
update(data) {
return data.helloEmail.email;
},
error() {
console.log('error');
this.$router.push({name: 'hello'});
}
},
},
};
</script>
<style scoped lang="scss">
@import "@/styles/_variables.scss";
@import "@/styles/_mixins.scss";
.text-link {
font-family: $sans-serif-font-family;
color: $color-brand;
}
.actions {
&__reset {
display: inline-block;
margin-left: $large-spacing;
}
}
.registration {
&__text {
font-family: $sans-serif-font-family;
margin-bottom: $small-spacing;
}
}
</style>

View File

@ -1,18 +1,7 @@
import login from '@/pages/login';
import hello from '@/pages/hello';
import betaLogin from '@/pages/beta-login';
import registration from '@/pages/registration';
export default [
{
path: '/login',
name: 'login',
component: login,
meta: {
layout: 'public',
public: true,
},
},
{
path: '/hello',
name: 'hello',
@ -31,13 +20,4 @@ export default [
public: true,
},
},
{
path: '/register',
component: registration,
name: 'registration',
meta: {
public: true,
layout: 'public',
},
}
];

View File

@ -10,7 +10,6 @@ import Router from 'vue-router';
import surveyPage from '@/pages/survey';
import styleGuidePage from '@/pages/styleguide';
import checkEmail from '@/pages/check-email';
import emailVerification from '@/pages/email-verification';
import licenseActivation from '@/pages/license-activation';
import forgotPassword from '@/pages/forgot-password';
import joinClass from '@/pages/joinClass';
@ -66,15 +65,6 @@ const routes = [
layout: 'public',
},
},
{
path: '/verify-email',
component: emailVerification,
name: 'emailVerification',
meta: {
public: true,
layout: 'public',
},
},
{
path: '/license-activation',
component: licenseActivation,
@ -112,6 +102,7 @@ const routes = [
localStorage.removeItem(postLoginRederictUrlKey);
return redirectUrl;
}
return '/';
default:
return '/unknown';
}

View File

@ -133,28 +133,6 @@ class HepClient:
if request is None and token is None:
raise HepClientNoTokenException
def customers_search(self, admin_token, email):
response = self._call('/rest/V1/customers/search?searchCriteria[filterGroups][0][filters][0][field]='
f'email&searchCriteria[filterGroups][0][filters][0][value]={email}',
additional_headers={'authorization': f'Bearer {admin_token}'})
json_data = response.json()
if len(json_data['items']) > 0:
return json_data['items'][0]
return None
def customers_by_id(self, admin_token, user_id):
response = self._call('/rest/V1/customers/{}'.format(user_id),
additional_headers={'authorization': f'Bearer {admin_token}'})
return response.json()
def _customer_orders(self, admin_token, customer_id):
url = ('/rest/V1/orders/?searchCriteria[filterGroups][0][filters][0]['
f'field]=customer_id&searchCriteria[filterGroups][0][filters][0][value]={customer_id}')
response = self._call(url, additional_headers={'authorization': 'Bearer {}'.format(admin_token)})
return response.json()
def coupon_redeem(self, coupon, customer_id):
try:
response = self._call(f'/rest/deutsch/V1/coupon/{coupon}/customer/{customer_id}', method='put')