Skip to content

Conversation

@belmirp
Copy link
Collaborator

@belmirp belmirp commented Mar 6, 2023

Closes #139

The following features are added/improved:

  • added IEmailService and implemented sending emails via AWS SES
  • added EmailVerified flag for account
  • added CleanupService to delete non-verified accounts and all of their related data
  • added RateLimitService to time-limit users from using actions that send emails
  • preventing users from registering accounts on free temporary email services
  • sending verification link when a new account is registered
  • sending verification link when the email is changed for an account
  • added ability to reset password for an account
  • added indicators on Player Card that the email is not verified

Warning:
Upon deployment to production, CleanupService will delete all accounts that didn't login for the past 1 month. This logic should be revised.

Steps to do before deployment:

  • request production access for AWS SES
  • generate production AWS AccessKey and SecretKey and inject the values into UT4MasterServer's appsettings

@belmirp belmirp requested a review from timiimit March 6, 2023 20:49
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the Conflicts label May 9, 2024
@github-actions
Copy link

github-actions bot commented May 9, 2024

Conflicts have been resolved.

{
var filter = (Builders<Account>.Filter.BitsAnyClear(f => f.Flags, (long)AccountFlags.EmailVerified) |
Builders<Account>.Filter.Exists(f => f.Flags, false)) &
Builders<Account>.Filter.Lt(f => f.LastLoginAt, DateTime.UtcNow.AddMonths(-1));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Builders<Account>.Filter.Lt(f => f.LastLoginAt, DateTime.UtcNow.AddMonths(-1));
Builders<Account>.Filter.Lt(f => f.LastLoginAt, DateTime.UtcNow.AddMonths(-3));

Increase time to 3 months because we are not really in a hurry to delete unused accounts.

public string? VerificationLinkGUID { get; set; }

[BsonIgnoreIfNull]
public DateTime? VerificationLinkExpiration { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make more sense to have something like LastEmailChangeAt because that gives more information and control than just having expiry date.

LastEmailChangeAt can be set to null when not needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties come in pair: GUID + ExpirationDate. Not sure if changing will help now because I used term "verification link" all over the place.

public string? ResetLinkGUID { get; set; }

[BsonIgnoreIfNull]
public DateTime? ResetLinkExpiration { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And something like LastPasswordChangeAt here.

LastPasswordChangeAt can be set to null when not needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties come in pair: GUID + ExpirationDate. Not sure if changing will help now because I used term "reset password" all over the place.

Host = applicationSettings.WebsiteDomain,
Port = applicationSettings.WebsitePort,
Path = "VerifyEmail",
Query = $"accountId={accountID}&guid={guid}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is accountId necessary? User should be logged in in order to verify email address.
When he is logged in, accountId is known.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is needed since verification link is accessed via anonymous endpoint.

public string WebsiteScheme { get; set; } = string.Empty;

/// <summary>
/// Used just to redirect users to correct domain when UT4UU is being used.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment for new uses.

Comment on lines +21 to +23
awsSettings.Value.AccessKey,
awsSettings.Value.SecretKey,
Amazon.RegionEndpoint.GetBySystemName(awsSettings.Value.RegionName));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check what happens, but server shouldn't crash if these are not correct. Instead errors should be logged.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that server will crash, instead global error handler will catch the error.

@timiimit
Copy link
Owner

timiimit commented May 9, 2024

Since this PR is named Account improvements we should also add Account.LastUsernameChangeAt in order to limit the frequency of username changes. First change would be allowed whenever. Then each subsequent change would be allowed after 6 months.

@timiimit
Copy link
Owner

timiimit commented May 9, 2024

Regarding the warning...

Upon deployment to production, CleanupService will delete all accounts that didn't login for the past 1 month. This logic should be revised.

We should probably just add a static hardcoded DateTime check whether some date has passed and only activate deletion after that date. Before that date we would notify everyone on discord & send email to every existing account (with real email).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add email verification

4 participants