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