Skip to content

Commit 3dca1e3

Browse files
authored
Merge pull request #204 from Gid733/master
Minor enhancements
2 parents a5f40f3 + 52ac751 commit 3dca1e3

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

eFormAPI/eFormAPI.Web/Controllers/AccountController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public async Task<OperationResult> ChangePassword([FromBody] ChangePasswordModel
5151
{
5252
if (!ModelState.IsValid)
5353
{
54-
var allErrors = ModelState.Values.SelectMany(v => v.Errors);
55-
return new OperationResult(false, string.Join(" ", allErrors.Select(x => x.ErrorMessage)));
54+
var allErrors = ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage);
55+
return new OperationResult(false, string.Join(" ", allErrors));
5656
}
5757

5858
return await _accountService.ChangePassword(model);
@@ -89,7 +89,7 @@ public async Task<OperationResult> ResetPassword([FromBody] ResetPasswordModel m
8989
{
9090
if (!ModelState.IsValid)
9191
{
92-
var allErrors = ModelState.Values.SelectMany(v => v.Errors);
92+
var allErrors = ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage);
9393
return new OperationResult(false, string.Join(" ", allErrors));
9494
}
9595

eFormAPI/eFormAPI.Web/Services/AccountService.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,24 @@ public async Task<OperationResult> UpdateUserSettings(UserSettingsModel model)
9797
if (!updateResult.Succeeded)
9898
{
9999
return new OperationResult(false,
100-
$"Error while updating user settings: {string.Join(", ", updateResult.Errors.Select(x => x.ToString()).ToArray())}");
100+
$"Error while updating user settings: {string.Join(", ", updateResult.Errors.Select(x => x.Description).ToArray())}");
101101
}
102102

103103
return new OperationResult(true);
104104
}
105105

106106
public async Task<OperationResult> ChangePassword(ChangePasswordModel model)
107107
{
108+
var user = await _userService.GetCurrentUserAsync();
108109
var result = await _userManager.ChangePasswordAsync(
109-
await _userService.GetCurrentUserAsync(),
110+
user,
110111
model.OldPassword,
111112
model.NewPassword);
112113

113114
if (!result.Succeeded)
114115
{
115-
return new OperationResult(false, string.Join(" ", result.Errors));
116+
var errors = result.Errors.Select(x => x.Description).ToArray();
117+
return new OperationResult(false, string.Join(" ", errors));
116118
}
117119

118120
return new OperationResult(true);
@@ -165,15 +167,15 @@ public async Task<OperationResult> ResetAdminPassword(string code)
165167
{
166168
return new OperationResult(false,
167169
_localizationService.GetString("ErrorWhileRemovingOldPassword") + ". \n" +
168-
string.Join(" ", removeResult.Errors));
170+
string.Join(" ", removeResult.Errors.Select(x=>x.Description).ToArray()));
169171
}
170172

171173
var addPasswordResult = await _userManager.AddPasswordAsync(user, defaultPassword);
172174
if (!addPasswordResult.Succeeded)
173175
{
174176
return new OperationResult(false,
175177
_localizationService.GetString("ErrorWhileAddNewPassword") + ". \n" +
176-
string.Join(" ", addPasswordResult.Errors));
178+
string.Join(" ", addPasswordResult.Errors.Select(x=>x.Description).ToArray()));
177179
}
178180

179181
return new OperationResult(true, _localizationService.GetString("YourEmailPasswordHasBeenReset", user.Email));
@@ -193,7 +195,7 @@ public async Task<OperationResult> ResetPassword(ResetPasswordModel model)
193195
return new OperationResult(true);
194196
}
195197

196-
return new OperationResult(false, string.Join(" ", result));
198+
return new OperationResult(false, string.Join(" ", result.Errors.Select(x=>x.Description).ToArray()));
197199
}
198200
}
199201
}

eFormAPI/eFormAPI.Web/Services/AdminService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public async Task<OperationResult> UpdateUser(UserRegisterModel userRegisterMode
158158
var result = await _userManager.UpdateAsync(user);
159159
if (!result.Succeeded)
160160
{
161-
return new OperationResult(false, string.Join(" ", result.Errors));
161+
return new OperationResult(false, string.Join(" ", result.Errors.Select(x=>x.Description).ToArray()));
162162
}
163163

164164
// password
@@ -230,7 +230,7 @@ public async Task<OperationResult> CreateUser(UserRegisterModel userRegisterMode
230230
var result = await _userManager.CreateAsync(user, userRegisterModel.Password);
231231
if (!result.Succeeded)
232232
{
233-
return new OperationResult(false, string.Join(" ", result.Errors));
233+
return new OperationResult(false, string.Join(" ", result.Errors.Select(x=>x.Description).ToArray()));
234234
}
235235

236236
// change role
@@ -281,7 +281,7 @@ public async Task<OperationResult> DeleteUser(int userId)
281281
var result = await _userManager.DeleteAsync(user);
282282
if (!result.Succeeded)
283283
{
284-
return new OperationResult(false, string.Join(" ", result.Errors));
284+
return new OperationResult(false, string.Join(" ", result.Errors.Select(x=>x.Description).ToArray()));
285285
}
286286

287287
return new OperationResult(true, _localizationService.GetString("UserParamWasDeleted", userId));

eform-client/src/app/common/services/auth/locale.service.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ export class LocaleService extends BaseService {
6565
initCookies(locale: string) {
6666
this.translateService.setDefaultLang('en-US');
6767
let culture = '';
68-
if (locale === 'da-DK') {
69-
culture = this.buildCookieValue('da');
70-
} else {
71-
culture = this.buildCookieValue('en-US');
72-
}
68+
if (locale === 'da-DK') {
69+
culture = this.buildCookieValue('da');
70+
} else if (locale === 'de-DE') {
71+
culture = this.buildCookieValue('de-DE');
72+
} else {
73+
culture = this.buildCookieValue('en-US');
74+
}
7375
this.cookieService.set('culture', culture, 9999999, '/');
7476
this.cookieService.set('locale', locale, 9999999, '/');
7577
}

eform-client/src/app/modules/eforms/eform-report/components/eform-report-page/eform-report-page.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class EformReportPageComponent implements OnInit {
4242
this.spinnerStatus = true;
4343
this.eformReportService.updateSingle(this.fullReportModel).subscribe((data) => {
4444
if (data && data.success) {
45-
45+
this.router.navigate(['/']).then();
4646
} this.spinnerStatus = false;
4747
});
4848
}

0 commit comments

Comments
 (0)