diff --git a/zero.Api/Endpoints/Users/UsersController.cs b/zero.Api/Endpoints/Users/UsersController.cs index 14b30ff0..039305f7 100644 --- a/zero.Api/Endpoints/Users/UsersController.cs +++ b/zero.Api/Endpoints/Users/UsersController.cs @@ -53,9 +53,24 @@ public class UsersController : ZeroApiController //public virtual Task> Create(ZeroUser saveModel) => CreateModel(saveModel); - //[HttpPut("{id}")] - //[ZeroAuthorize(UserPermissions.Update)] - //public virtual Task> Update(string id, ZeroUser updateModel, [FromQuery] string changeToken = null) => UpdateModel(id, updateModel, changeToken); + [HttpPut("{id}")] + [ZeroAuthorize(UserPermissions.Update)] + public virtual async Task> Update(string id, ZeroUser updateModel, [FromQuery] string changeToken = null) + { + if (id != updateModel.Id) + { + return BadRequest(Result.Fail(nameof(id), "@errors.onupdate.noidmatch")); + } + + Result result = await Users.Save(updateModel); + + if (Hints.ResponsePreference == ApiResponsePreference.Minimal) + { + return result.WithoutModel(); + } + + return result; + } //[HttpDelete("{id}")] diff --git a/zero.Backoffice.UI/app/components/ui-form.vue b/zero.Backoffice.UI/app/components/ui-form.vue index ebf24253..a0d9e9ee 100644 --- a/zero.Backoffice.UI/app/components/ui-form.vue +++ b/zero.Backoffice.UI/app/components/ui-form.vue @@ -53,10 +53,10 @@ }), watch: { - '$route': function () - { - this.$emit('load', this); - }, + //'$route': function (val) + //{ + // this.$emit('load', this); + //}, state(val) { this.slotProps.state = val; diff --git a/zero.Backoffice.UI/app/editor/register.ts b/zero.Backoffice.UI/app/editor/register.ts index c819f1fc..aa293d7e 100644 --- a/zero.Backoffice.UI/app/editor/register.ts +++ b/zero.Backoffice.UI/app/editor/register.ts @@ -6,4 +6,5 @@ export default function (app: App) app.component('ui-editor', defineAsyncComponent(() => import('./ui-editor.vue'))); app.component('ui-editor-infos', defineAsyncComponent(() => import('./ui-editor-infos.vue'))); app.component('ui-editor-header', defineAsyncComponent(() => import('./ui-editor-header.vue'))); + app.component('ui-editor-page', defineAsyncComponent(() => import('./ui-editor-page.vue'))); }; \ No newline at end of file diff --git a/zero.Backoffice.UI/app/editor/ui-editor-page.vue b/zero.Backoffice.UI/app/editor/ui-editor-page.vue new file mode 100644 index 00000000..8ca4bc70 --- /dev/null +++ b/zero.Backoffice.UI/app/editor/ui-editor-page.vue @@ -0,0 +1,87 @@ + + + + \ No newline at end of file diff --git a/zero.Backoffice.UI/app/modules/countries/country.vue b/zero.Backoffice.UI/app/modules/countries/country.vue index 48d0c7a9..416bf57e 100644 --- a/zero.Backoffice.UI/app/modules/countries/country.vue +++ b/zero.Backoffice.UI/app/modules/countries/country.vue @@ -1,57 +1,11 @@  - - - \ No newline at end of file + \ No newline at end of file diff --git a/zero.Backoffice.UI/app/modules/languages/language.vue b/zero.Backoffice.UI/app/modules/languages/language.vue index 81c46a3f..1d56380b 100644 --- a/zero.Backoffice.UI/app/modules/languages/language.vue +++ b/zero.Backoffice.UI/app/modules/languages/language.vue @@ -1,50 +1,11 @@  \ No newline at end of file diff --git a/zero.Backoffice.UI/app/modules/mails/mailtemplate.vue b/zero.Backoffice.UI/app/modules/mails/mailtemplate.vue index 8d9b8cea..b06fb6c6 100644 --- a/zero.Backoffice.UI/app/modules/mails/mailtemplate.vue +++ b/zero.Backoffice.UI/app/modules/mails/mailtemplate.vue @@ -1,49 +1,10 @@  - \ No newline at end of file diff --git a/zero.Backoffice.UI/app/modules/translations/translation.vue b/zero.Backoffice.UI/app/modules/translations/translation.vue index ee319b4a..eaefad0f 100644 --- a/zero.Backoffice.UI/app/modules/translations/translation.vue +++ b/zero.Backoffice.UI/app/modules/translations/translation.vue @@ -1,52 +1,10 @@  - \ No newline at end of file diff --git a/zero.Backoffice.UI/app/modules/users/api.ts b/zero.Backoffice.UI/app/modules/users/api.ts index e344f963..34fc5f6a 100644 --- a/zero.Backoffice.UI/app/modules/users/api.ts +++ b/zero.Backoffice.UI/app/modules/users/api.ts @@ -10,7 +10,7 @@ export default { //create: (model: any, config?: ApiRequestConfig) => post('countries', model, config), - //update: (model: any, config?: ApiRequestConfig) => put('countries/' + model.id, model, config), + update: (model: any, config?: ApiRequestConfig) => put('users/' + model.id, model, config), //delete: (id: string, config?: ApiRequestConfig) => del('countries/' + id, null, config), diff --git a/zero.Backoffice.UI/app/modules/users/user.vue b/zero.Backoffice.UI/app/modules/users/user.vue index 15f7992c..59740bca 100644 --- a/zero.Backoffice.UI/app/modules/users/user.vue +++ b/zero.Backoffice.UI/app/modules/users/user.vue @@ -1,49 +1,11 @@  \ No newline at end of file diff --git a/zero.Core/Identity/Services/UserService.cs b/zero.Core/Identity/Services/UserService.cs index 40a277bf..07649c35 100644 --- a/zero.Core/Identity/Services/UserService.cs +++ b/zero.Core/Identity/Services/UserService.cs @@ -62,9 +62,10 @@ public class UserService : IUserService if (!model.Id.IsNullOrEmpty()) { - ZeroUser origin = await GetUserById(model.Id); - isUpdate = origin != null; - updateSecurityStamp = origin != null && model.PasswordHash != origin.PasswordHash; + // TODO throws "Attempted to associate a different object with id ..." + //ZeroUser origin = await GetUserById(model.Id); + isUpdate = true; // origin != null; + updateSecurityStamp = true; // origin != null && model.PasswordHash != origin.PasswordHash; } Result result = isUpdate ? await Operations.Update(model) : await Operations.Create(model); diff --git a/zero.Demo/appsettings.Development.json b/zero.Demo/appsettings.Development.json index 770d3e93..55f0d61c 100644 --- a/zero.Demo/appsettings.Development.json +++ b/zero.Demo/appsettings.Development.json @@ -3,6 +3,7 @@ "Logging": { "LogLevel": { "Default": "Information", + "zero": "Debug", "Microsoft.AspNetCore": "Warning" } }