Skip to content

Commit 3745e31

Browse files
Merge pull request #21 from kingscode/KCI-87
Update scaffold
2 parents 8c54526 + 1ce93f1 commit 3745e31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+956
-663
lines changed

generator/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = (api, options) => {
1010
'vuex-persistedstate': '^2.5.4',
1111
'lodash.clonedeep': '^4.5.0',
1212
'css-vars-ponyfill': '^2.1.2',
13+
'qs': '^6.9.4',
1314
'vue-router': '3.3.4',
1415
},
1516
});
@@ -19,12 +20,18 @@ module.exports = (api, options) => {
1920
'@fortawesome/fontawesome-pro': '^5.8.1',
2021
},
2122
});
23+
} else {
24+
api.extendPackage({
25+
dependencies: {
26+
'@fortawesome/fontawesome-free': '^5.14.0',
27+
},
28+
});
2229
}
2330

2431
if (options.useCrud) {
2532
api.extendPackage({
2633
dependencies: {
27-
'@kingscode/vuetify-resource': '^1.4.1',
34+
'@kingscode/vuetify-resource': '^2.0.3',
2835
},
2936
});
3037
api.render('./templates/Crud', options);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {post} from '../../implementation/app/wrapper';
1+
import {post} from '../../implementation/app';
22

33
export default function (email, password) {
44
return post('auth/login', {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {post} from '../../implementation/app/wrapper.js';
1+
import {post} from '../../implementation/app';
22

33
export default function () {
44
return post('auth/logout');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {post} from '../../implementation/app/wrapper.js';
1+
import {post} from '../../implementation/app';
22

33
function passwordForgotten(email) {
44
return post('password/forgotten', {
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
import {post} from '../../implementation/app/wrapper.js';
1+
import {post} from '../../implementation/app';
22

3-
export default function (email, name) {
3+
function register(email, name) {
44
return post('registration', {
55
email, name,
66
});
77
}
8+
9+
function verify(token, email, password, passwordConfirmation) {
10+
return post('registration/verify', {
11+
token: token,
12+
email: email,
13+
password: password,
14+
password_confirmation: passwordConfirmation,
15+
});
16+
}
17+
18+
export {
19+
register,
20+
verify,
21+
};

generator/templates/Authorisation/src/api/endpoints/password/forgotten.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {post} from '../../implementation/app/wrapper.js';
1+
import {post} from '../../implementation/app';
22

33
export default function (email) {
44
return post('password/forgotten', {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {post} from '../../implementation/app/wrapper.js';
1+
import {post} from '../../implementation/app';
22

33
export default async function (email, token, password, passwordConfirmation) {
44
return post('registration', {
55
email: email,
66
token: token,
77
password: password,
8-
password_confirmation: passwordConfirmation
8+
password_confirmation: passwordConfirmation,
99
});
1010
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import axios from '../implementation/app';
2+
3+
/**
4+
* @param user {User}
5+
*/
6+
function create(user) {
7+
return axios.post('user', user);
8+
}
9+
10+
/**
11+
* @param user {User}
12+
*/
13+
function update(user) {
14+
return axios.put(`user/${user.id}`, user);
15+
}
16+
17+
/**
18+
* @param userId {number}
19+
*/
20+
function destroy(userId) {
21+
return axios.delete(`user/${userId}`);
22+
}
23+
24+
export {
25+
create,
26+
update,
27+
destroy,
28+
};

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<script>
4444
import LoginRequest from '../../api/endpoints/authorisation/login';
4545
import {mapGetters} from 'vuex';
46+
import {getRateLimitMinutes} from '../../api/util/response.js';
4647
4748
export default {
4849
name: 'LoginCard',
@@ -61,7 +62,7 @@ export default {
6162
},
6263
computed: {
6364
...mapGetters({
64-
findError: 'Error/find',
65+
findError: 'error/find',
6566
}),
6667
},
6768
methods: {
@@ -70,9 +71,20 @@ export default {
7071
LoginRequest(this.form.email, this.form.password)
7172
.then(res => {
7273
this.isRedirecting = true;
73-
this.redirectToAuthDispense(res.data.token);
74+
this.redirectToAuthDispense(res.data.data.token);
75+
})
76+
.catch(err => {
77+
const response = err.response;
78+
const status = response.status;
79+
80+
if (status === 429) {
81+
this.errorMessage =
82+
`Je hebt te veel foutieve inlog pogingen gedaan.
83+
Probeer het over ${getRateLimitMinutes(response, 15)} minuten opnieuw`;
84+
} else {
85+
this.errorMessage = this.findError('email');
86+
}
7487
})
75-
.catch(() => this.errorMessage = this.findError('email'))
7688
.finally(() => this.isLoading = false);
7789
},
7890
redirectToAuthDispense(token) {

generator/templates/Authorisation/src/components/Authorisation/PasswordForgottenCard.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,15 @@ export default {
4949
if (!this.isValid) return;
5050
5151
this.isLoading = true;
52+
this.alertMessage = '';
53+
this.alertType = 'error';
5254
5355
ForgottenRequest(this.form.email)
5456
.then(() => {
5557
this.alertMessage = 'Er is een wachtwoord vergeten mail verstuurd mits er een account bestaat met het gegeven email adres.';
5658
this.alertType = 'success';
5759
})
58-
.catch(() => {
59-
this.alertMessage = 'De ingevulde gegevens kloppen niet.';
60-
this.alertType = 'error';
61-
})
60+
.catch(() => this.alertMessage = 'De ingevulde gegevens kloppen niet.')
6261
.finally(() => this.isLoading = false);
6362
},
6463
},

0 commit comments

Comments
 (0)