Skip to content

Commit d4d90f9

Browse files
committed
Corrected #17
1 parent fb9d5f9 commit d4d90f9

File tree

11 files changed

+50
-9
lines changed

11 files changed

+50
-9
lines changed

src/Server/Coderr.Server.Api/Core/Users/Commands/UpdatePersonalSettings.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ namespace codeRR.Server.Api.Core.Users.Commands
77
/// </summary>
88
public class UpdatePersonalSettings : Command
99
{
10+
/// <summary>
11+
/// Change email address
12+
/// </summary>
13+
/// <remarks>
14+
/// <para>
15+
/// Do not required additional verification, we trust the user once it has an activated account.
16+
/// </para>
17+
/// </remarks>
18+
public string EmailAddress { get; set; }
19+
1020
/// <summary>
1121
/// First name (if specified)
1222
/// </summary>

src/Server/Coderr.Server.Api/Core/Users/Queries/GetUserSettingsResult.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ namespace codeRR.Server.Api.Core.Users.Queries
1010
/// </remarks>
1111
public class GetUserSettingsResult
1212
{
13+
/// <summary>
14+
/// From the user account, always specified.
15+
/// </summary>
16+
public string EmailAddress { get; set; }
17+
1318
/// <summary>
1419
/// First name (optional)
1520
/// </summary>
@@ -21,7 +26,7 @@ public class GetUserSettingsResult
2126
public string LastName { get; set; }
2227

2328
/// <summary>
24-
/// Cell phone number (otional, but required for text notifications).
29+
/// Cell phone number (optional, but required for text notifications).
2530
/// </summary>
2631
public string MobileNumber { get; set; }
2732

src/Server/Coderr.Server.App/Core/Users/WebApi/GetUserSettingsHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public async Task<GetUserSettingsResult> ExecuteAsync(GetUserSettings query)
3131
FirstName = user.FirstName,
3232
LastName = user.LastName,
3333
MobileNumber = user.MobileNumber,
34+
EmailAddress = user.EmailAddress,
3435
Notifications = new NotificationSettings
3536
{
3637
NotifyOnReOpenedIncident = settings.ReopenedIncident.ConvertEnum<NotificationState>(),

src/Server/Coderr.Server.App/Core/Users/WebApi/UpdatePersonalSettingsHandler.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Threading.Tasks;
33
using codeRR.Server.Api.Core.Users.Commands;
4+
using codeRR.Server.App.Core.Accounts;
45
using DotNetCqs;
56
using Griffin.Container;
67

@@ -13,16 +14,18 @@ namespace codeRR.Server.App.Core.Users.WebApi
1314
public class UpdatePersonalSettingsHandler : ICommandHandler<UpdatePersonalSettings>
1415
{
1516
private readonly IUserRepository _userRepository;
17+
private readonly IAccountRepository _accountRepository;
1618

1719
/// <summary>
1820
/// Creates a new instance of <see cref="UpdatePersonalSettingsHandler" />.
1921
/// </summary>
2022
/// <param name="userRepository">repos</param>
23+
/// <param name="accountRepository">Used to change email</param>
2124
/// <exception cref="ArgumentNullException">userRepository</exception>
22-
public UpdatePersonalSettingsHandler(IUserRepository userRepository)
25+
public UpdatePersonalSettingsHandler(IUserRepository userRepository, IAccountRepository accountRepository)
2326
{
24-
if (userRepository == null) throw new ArgumentNullException("userRepository");
25-
_userRepository = userRepository;
27+
_userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
28+
_accountRepository = accountRepository ?? throw new ArgumentNullException(nameof(accountRepository));
2629
}
2730

2831
/// <summary>
@@ -34,13 +37,24 @@ public UpdatePersonalSettingsHandler(IUserRepository userRepository)
3437
/// </returns>
3538
public async Task ExecuteAsync(UpdatePersonalSettings command)
3639
{
37-
if (command == null) throw new ArgumentNullException("command");
40+
if (command == null) throw new ArgumentNullException(nameof(command));
3841

3942
var user = await _userRepository.GetUserAsync(command.UserId);
4043
user.FirstName = command.FirstName;
4144
user.LastName = command.LastName;
4245
user.MobileNumber = command.MobileNumber;
46+
47+
if (command.EmailAddress != null)
48+
user.EmailAddress = command.EmailAddress;
49+
4350
await _userRepository.UpdateAsync(user);
51+
52+
if (command.EmailAddress == null)
53+
return;
54+
55+
var account = await _accountRepository.GetByIdAsync(user.AccountId);
56+
account.SetVerifiedEmail(command.EmailAddress);
57+
await _accountRepository.UpdateAsync(account);
4458
}
4559
}
4660
}

src/Server/Coderr.Server.SqlServer/Analysis/AnalyticsRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public void CreateIncident(IncidentBeingAnalyzed incident)
7878
using (var cmd = _unitOfWork.CreateCommand())
7979
{
8080
cmd.CommandText =
81-
"INSERT INTO Incidents (ReportHashCode, ApplicationId, CreatedAtUtc, HashCodeIdentifier, ReportCount, UpdatedAtUtc, Description, FullName, IsReOpened)" +
82-
" VALUES (@ReportHashCode, @ApplicationId, @CreatedAtUtc, @HashCodeIdentifier, @ReportCount, @UpdatedAtUtc, @Description, @FullName, 0);select SCOPE_IDENTITY();";
81+
"INSERT INTO Incidents (ReportHashCode, ApplicationId, CreatedAtUtc, HashCodeIdentifier, StackTrace, ReportCount, UpdatedAtUtc, Description, FullName, IsReOpened)" +
82+
" VALUES (@ReportHashCode, @ApplicationId, @CreatedAtUtc, @HashCodeIdentifier, @StackTrace, @ReportCount, @UpdatedAtUtc, @Description, @FullName, 0);select SCOPE_IDENTITY();";
8383
cmd.AddParameter("Id", incident.Id);
8484
cmd.AddParameter("ReportHashCode", incident.ReportHashCode);
8585
cmd.AddParameter("ApplicationId", incident.ApplicationId);

src/Server/Coderr.Server.Web/Scripts/Models/AllModels.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Server/Coderr.Server.Web/Scripts/Models/AllModels.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ module codeRR.Core.Users.Queries {
420420

421421
export class GetUserSettingsResult {
422422
public static TYPE_NAME: string = 'GetUserSettingsResult';
423+
public EmailAddress: string;
423424
public FirstName: string;
424425
public LastName: string;
425426
public MobileNumber: string;
@@ -442,6 +443,7 @@ module codeRR.Core.Users.Commands {
442443

443444
export class UpdatePersonalSettings {
444445
public static TYPE_NAME: string = 'UpdatePersonalSettings';
446+
public EmailAddress: string;
445447
public FirstName: string;
446448
public LastName: string;
447449
public MobileNumber: string;

src/Server/Coderr.Server.Web/ViewModels/User/SettingsViewModel.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Server/Coderr.Server.Web/ViewModels/User/SettingsViewModel.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Server/Coderr.Server.Web/ViewModels/User/SettingsViewModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module codeRR.User {
4646
cmd.FirstName = dto.FirstName;
4747
cmd.LastName = dto.LastName;
4848
cmd.MobileNumber = dto.MobileNumber;
49+
cmd.EmailAddress = dto.EmailAddress;
4950
CqsClient.command(cmd);
5051
humane.log("Settings have been saved.");
5152
}

0 commit comments

Comments
 (0)