Skip to content

Commit bb4521b

Browse files
Merge pull request #31 from kingscode/KCI-140
KCI-140 User can Resend their invitation
2 parents 378bef9 + 730a3cc commit bb4521b

File tree

6 files changed

+43
-23
lines changed

6 files changed

+43
-23
lines changed

generator/templates/Authorisation/src/api/endpoints/authorisation/register.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ function acceptInvitation(email, token, password, passwordConfirmation) {
1818
});
1919
}
2020

21+
function resendInvitation(email) {
22+
return post('invitation/resend', {
23+
email,
24+
});
25+
}
26+
2127
export {
2228
verify,
2329
acceptInvitation,
30+
resendInvitation,
2431
};

generator/templates/Authorisation/src/components/authorisation/LoginCard.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
>
1111
{{ errorMessage }}
1212
</v-alert>
13+
<v-alert v-if="$route.query.message"
14+
class="mb-10"
15+
transition="fade-transition"
16+
type="success"
17+
>
18+
{{ $t(`authorisation.login.messages.${$route.query.message}`) }}
19+
</v-alert>
1320
<k-field-group language-prefix="authorisation.fields">
1421
<KTextField field="email"
1522
autofocus

generator/templates/Authorisation/src/components/authorisation/PasswordResetCard.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<VCardTitle class="title" v-text="$t('authorisation.passwordReset.title')"/>
55
<v-card-text>
66
<v-alert
7-
:type="alertType"
7+
type="error"
88
:value="!!alertMessage.length"
99
class="mb-10"
1010
transition="fade-transition"
@@ -63,7 +63,6 @@ export default {
6363
},
6464
data() {
6565
return {
66-
alertType: 'success',
6766
alertMessage: '',
6867
isLoading: false,
6968
isValid: false,
@@ -85,16 +84,13 @@ export default {
8584
if (!this.isValid) return;
8685
8786
this.isLoading = true;
88-
this.alertType = 'error';
8987
this.errorMessage = '';
9088
9189
resetRequest(this.form.email, this.token, this.form.password, this.form.passwordConfirmation)
9290
.then(() => {
93-
this.alertType = 'success';
94-
this.alertMessage = this.$t('authorisation.passwordReset.successMessage');
91+
this.$router.push({name: 'login', query: {message: 'passwordResetSuccess'}});
9592
})
9693
.catch((error) => {
97-
this.alertType = 'error';
9894
const { response } = error;
9995
const { status } = response;
10096

generator/templates/Authorisation/src/locales/nl/authorisation.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
22
"login": {
33
"title": "Inloggen",
4-
"successMessage": "Je bent ingelogd, we sturen je nu door."
4+
"successMessage": "Je bent ingelogd, we sturen je nu door.",
5+
"messages": {
6+
"acceptInvitationSuccess": "Je account is geactiveerd, je kunt nu inloggen.",
7+
"resendInvitationSuccess": "De uitnodiging is opnieuw verstuurd, controleer je mail.",
8+
"passwordResetSuccess": "Je wachtwoord is veranderd, je kunt nu inloggen.",
9+
"registrationVerify": "Je registratie is voltooid, je kunt nu inloggen."
10+
}
511
},
612
"registrationVerify": {
713
"title": "Registratie afronden",
8-
"successMessage": "Je registratie is voltooid, je kunt nu inloggen.",
914
"errorMessage": "Er is iets misgegaan. Waarschijnlijk is de registratie link uit je mail verlopen."
1015
},
1116
"passwordForgotten": {
@@ -15,15 +20,14 @@
1520
},
1621
"passwordReset": {
1722
"title": "Wachtwoord opnieuw instellen",
18-
"successMessage": "Je wachtwoord is veranderd, je kunt nu inloggen.",
1923
"errorMessage": "Er is iets misgegaan. Waarschijnlijk is de wachtwoord reset link uit je mail verlopen.",
2024
"request": "Wachtwoord aanvragen"
2125
},
2226
"invitationAccept": {
2327
"title": "Uitnodiging accepteren",
2428
"request": "Uitnodiging accepteren",
25-
"successMessage": "Je account is geactiveerd, je kunt nu inloggen.",
26-
"errorMessage": "Er is iets misgegaan. Waarschijnlijk is de uitnodigings link uit je mail verlopen."
29+
"errorMessage": "Er is iets misgegaan. Waarschijnlijk is de uitnodigings link uit je mail verlopen.",
30+
"resend": "Opnieuw versturen"
2731
},
2832
"fields": {
2933
"email": "E-mail",

generator/templates/Authorisation/src/views/authorisation/InvitationAccept.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99
:value="!!alertMessage.length"
1010
class="mb-10"
1111
transition="fade-transition"
12-
:type="alertType"
12+
type="error"
1313
>
1414
{{ alertMessage }}
15+
<v-row class="mx-0 mt-3 justify-end">
16+
<v-btn v-if="errorCode === 400 && !!alertMessage.length" outlined @click="handleResend">
17+
{{ $t('authorisation.invitationAccept.resend') }}
18+
</v-btn>
19+
</v-row>
1520
</v-alert>
1621

1722
<k-field-group language-prefix="authorisation.fields">
@@ -54,7 +59,7 @@
5459
</template>
5560

5661
<script lang="js">
57-
import { acceptInvitation } from '@/api/endpoints/authorisation/register.js';
62+
import { acceptInvitation, resendInvitation } from '@/api/endpoints/authorisation/register.js';
5863
import { getRateLimitMinutes } from '@/api/util/response.js';
5964
import KFieldGroup from '@/components/crud/fields/KFieldGroup.vue';
6065
import KTextField from '@/components/crud/fields/KTextField.vue';
@@ -68,13 +73,14 @@ export default {
6873
},
6974
data() {
7075
return {
71-
alertType: 'success',
76+
errorCode: 0,
7277
alertMessage: '',
7378
isLoading: false,
79+
isValid: false,
80+
7481
email: this.$route.query.email,
7582
password: '',
7683
passwordConfirmation: '',
77-
isValid: false,
7884
};
7985
},
8086
computed: {
@@ -99,18 +105,21 @@ export default {
99105
}
100106
},
101107
methods: {
108+
async handleResend() {
109+
await resendInvitation(this.email);
110+
this.$router.push({name: 'login', query: {message: 'resendInvitationSuccess'}});
111+
},
102112
handleAccept() {
103113
this.isLoading = true;
104114
acceptInvitation(this.email, this.$route.params.token, this.password, this.passwordConfirmation)
105115
.then(() => {
106-
this.alertType = 'success';
107-
this.alertMessage = this.$t('authorisation.invitationAccept.successMessage');
116+
this.$router.push({name: 'login', query: {message: 'acceptInvitationSuccess'}});
108117
})
109118
.catch((error) => {
110-
this.alertType = 'error';
111119
const { response } = error;
112120
const { status } = response;
113121
122+
this.errorCode = status;
114123
if (status === 429) {
115124
this.alertMessage = this.$t('errors.429', { minutes: getRateLimitMinutes(response) });
116125
} else if (status === 400) {

generator/templates/Authorisation/src/views/authorisation/RegistrationVerify.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<VCardTitle class="title" v-text="$t('authorisation.registrationVerify.title')"/>
77
<v-card-text>
88
<v-alert
9-
:type="alertType"
9+
type="error"
1010
:value="!!alertMessage.length"
1111
text
1212
transition="fade-transition"
@@ -67,7 +67,6 @@ export default {
6767
email: '',
6868
},
6969
isLoading: false,
70-
alertType: 'success',
7170
alertMessage: '',
7271
valid: true,
7372
showPassword: false,
@@ -86,14 +85,12 @@ export default {
8685
8786
verify(token, this.form.email, this.form.password, this.form.passwordConfirmation)
8887
.then(() => {
89-
this.alertMessage = this.$t('authorisation.registrationVerify.successMessage');
90-
this.alertType = 'success';
88+
this.$router.push({name: 'login', query: {message: 'registrationVerify'}});
9189
})
9290
.catch((error) => {
9391
const { response } = error;
9492
const { status } = response;
9593
96-
this.alertType = 'error';
9794
if (status === 429) {
9895
this.alertMessage = this.$t('errors.429', { minutes: getRateLimitMinutes(response) });
9996
} else if (status === 400) {

0 commit comments

Comments
 (0)