/// <summary> /// Triggers the <see cref="EmailConfirmed"/> event /// </summary> protected void TriggerEmailConfirmed(IAccountData account) { if (EmailConfirmed != null) { EmailConfirmed.Invoke(account); } }
/// <summary> /// Handles e-mail confirmation request /// </summary> /// <param name="message"></param> protected virtual void HandleEmailConfirmation(IIncommingMessage message) { var code = message.AsString(); var extension = message.Peer.GetExtension <IUserExtension>(); if (extension == null || extension.AccountData == null) { message.Respond("Invalid session", ResponseStatus.Unauthorized); return; } if (extension.AccountData.IsGuest) { message.Respond("Guests cannot confirm e-mails", ResponseStatus.Unauthorized); return; } if (extension.AccountData.IsEmailConfirmed) { // We still need to respond with "success" in case // response is handled somehow on the client message.Respond("Your email is already confirmed", ResponseStatus.Success); return; } var db = Msf.Server.DbAccessors.GetAccessor <IAuthDatabase>(); db.GetEmailConfirmationCode(extension.AccountData.Email, requiredCode => { if (requiredCode != code) { message.Respond("Invalid activation code", ResponseStatus.Error); return; } // Confirm e-mail extension.AccountData.IsEmailConfirmed = true; // Update account db.UpdateAccount(extension.AccountData, () => { }); // Respond with success message.Respond(ResponseStatus.Success); // Invoke the event if (EmailConfirmed != null) { EmailConfirmed.Invoke(extension.AccountData); } }); }
/// <summary> /// Triggers the <see cref="EmailConfirmed" /> event /// </summary> protected void TriggerEmailConfirmed(IAccountData account) { EmailConfirmed?.Invoke(account); }