mirror of https://github.com/MarceauKa/shaark.git
🐛 Fix user creation and deletion
This commit is contained in:
parent
6b27a2805f
commit
363f58ca04
|
@ -5,7 +5,7 @@ APP_ENV=local
|
|||
APP_KEY=
|
||||
# set debug to false in production
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://dev.shaark
|
||||
APP_URL=http://127.0.0.1:8000
|
||||
APP_TIMEZONE=Europe/Paris
|
||||
# "en", "fr", "de", "nl" or "ja"
|
||||
APP_LANG=en
|
||||
|
|
|
@ -80,9 +80,9 @@ class UsersController extends Controller
|
|||
$admin = User::isAdmin()->first();
|
||||
|
||||
if ($admin) {
|
||||
Post::where('user_id', $id)->update('user_id', $admin->id);
|
||||
Post::where('user_id', $id)->update(['user_id' => $admin->id]);
|
||||
} else {
|
||||
Post::where('user_id', $id)->update('user_id', null);
|
||||
Post::where('user_id', $id)->update(['user_id' => null]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Unreleased
|
||||
|
||||
## Fixed
|
||||
|
||||
- Create and delete users ([#77](https://github.com/MarceauKa/shaark/issues/77), [#87](https://github.com/MarceauKa/shaark/issues/87))
|
||||
|
||||
## Changed
|
||||
|
||||
- Default user email is now `shaark@example.com`
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"/js/app.js": "/js/app.js?id=29ae6a7c36dbf9021add",
|
||||
"/js/app.js": "/js/app.js?id=6454f6e14b5042d95985",
|
||||
"/css/app.css": "/css/app.css?id=b8b03307e0cd699952d1",
|
||||
"/js/manifest.js": "/js/manifest.js?id=3c768977c2574a34506e",
|
||||
"/js/vendor.js": "/js/vendor.js?id=11a927bf070f02d1f22c"
|
||||
|
|
|
@ -70,9 +70,9 @@ export default {
|
|||
],
|
||||
|
||||
props: {
|
||||
user: {
|
||||
editing: {
|
||||
type: Object|Boolean,
|
||||
required: false,
|
||||
required: true,
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
|
@ -85,23 +85,24 @@ export default {
|
|||
},
|
||||
|
||||
mounted() {
|
||||
if (this.user) {
|
||||
this.setUser(this.user);
|
||||
if (this.editing !== false) {
|
||||
this.setUser(this.editing);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
submit() {
|
||||
this.loading = true;
|
||||
let editing = this.editing !== false;
|
||||
|
||||
axios.request({
|
||||
method: this.user ? 'PUT' : 'POST',
|
||||
url: this.user ? this.user.url_update : '/api/manage/users',
|
||||
method: editing ? 'PUT' : 'POST',
|
||||
url: editing ? this.editing.url_update : '/api/manage/users',
|
||||
data: this.form
|
||||
}).then(response => {
|
||||
this.$toasted.success(this.__("Saved"));
|
||||
|
||||
if (this.user) {
|
||||
if (this.editing) {
|
||||
this.loading = false;
|
||||
} else {
|
||||
this.form = defaultUser();
|
||||
|
@ -110,6 +111,7 @@ export default {
|
|||
this.resetFormError();
|
||||
this.$emit('submited');
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
if (error.response.data.status === 'error') {
|
||||
this.$toasted.error(error.response.data.message);
|
||||
} else {
|
||||
|
@ -134,7 +136,7 @@ export default {
|
|||
},
|
||||
|
||||
watch: {
|
||||
user: function (value) {
|
||||
editing(value) {
|
||||
this.setUser(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</div>
|
||||
|
||||
<div class="card-footer" v-if="creating || editing">
|
||||
<user-form :user="editing" @submited="formSubmited()"></user-form>
|
||||
<user-form :editing="editing" @submited="formSubmited()"></user-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -93,7 +93,7 @@ export default {
|
|||
|
||||
edit(user) {
|
||||
this.creating = false;
|
||||
this.editing = user;
|
||||
this.editing = { ...user };
|
||||
},
|
||||
|
||||
formSubmited() {
|
||||
|
|
Loading…
Reference in New Issue