Skip to content

DNN-7818: add send verification mail link in unverified message. #3144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Web.Http;
using DotNetNuke.Common;
using DotNetNuke.Entities.Users;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.Social.Notifications;
using DotNetNuke.Web.Api;
using DotNetNuke.Services.Mail;
Expand Down Expand Up @@ -76,6 +77,32 @@ public HttpResponseMessage Reject(NotificationDTO postData)
return Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" });
}

[HttpPost]
[DnnAuthorize]
[ValidateAntiForgeryToken]
public HttpResponseMessage SendVerificationMail(NotificationDTO postData)
{
if (UserInfo.Membership.Approved)
{
throw new UserAlreadyVerifiedException();
}

if (!UserInfo.IsInRole("Unverified Users"))
{
throw new InvalidVerificationCodeException();
}

var message = Mail.SendMail(UserInfo, MessageType.UserRegistrationVerified, PortalSettings);
if (string.IsNullOrEmpty(message))
{
return Request.CreateResponse(HttpStatusCode.OK, new {Result = Localization.GetSafeJSString("VerificationMailSendSuccessful", Localization.SharedResourceFile) });
}
else
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, message);
}
}

private UserInfo GetUser(NotificationDTO notificationDto)
{
var notification = NotificationsController.Instance.GetNotification(notificationDto.NotificationId);
Expand Down
3 changes: 3 additions & 0 deletions DNN Platform/Library/UI/Skins/Skin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,9 @@ protected override void OnInit(EventArgs e)
messageType = (ModuleMessage.ModuleMessageType)Enum.Parse(typeof (ModuleMessage.ModuleMessageType), HttpContext.Current.Items[OnInitMessageType].ToString(), true);
}
AddPageMessage(this, string.Empty, HttpContext.Current.Items[OnInitMessage].ToString(), messageType);

JavaScript.RequestRegistration(CommonJs.DnnPlugins);
ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
}

//Process the Panes attributes
Expand Down
5 changes: 4 additions & 1 deletion Website/App_GlobalResources/SharedResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@
<value>Delete</value>
</data>
<data name="UnverifiedUser.Text" xml:space="preserve">
<value>You are using an unverified account. Please verify your account by clicking on the link contained in the verification email that has been sent to you.</value>
<value>You are using an unverified account. Please verify your account by clicking on the link contained in the verification email that has been sent to you. Click &lt;a href="#" class="send-verification-mail"&gt;here&lt;/a&gt; to re-send the verification mail.</value>
</data>
<data name="DayAgo.Text" xml:space="preserve">
<value>{0} day ago</value>
Expand Down Expand Up @@ -1986,4 +1986,7 @@ If you expect this addition, then just ignore this email; otherwise, an immediat
<data name="OAuthConfigBase_HostConfig.Text" xml:space="preserve">
<value>Use Host Configuration? </value>
</data>
<data name="VerificationMailSendSuccessful.Text" xml:space="preserve">
<value>Verification Mail Send Successful.</value>
</data>
</root>
29 changes: 29 additions & 0 deletions Website/Resources/Shared/scripts/dnn.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -4286,9 +4286,38 @@
}
});
};

var handlerSendVerificationMailLink = function() {
$(document.body).on('click', 'a.send-verification-mail', function(e) {
e.preventDefault();

var service = $.dnnSF();
var url = service.getServiceRoot('InternalServices') + 'NewUserNotificationService/SendVerificationMail';
var antiForgeryToken = $('input[name="__RequestVerificationToken"]').val();
url += '?__RequestVerificationToken=' + antiForgeryToken;

$.ajax({
url: url,
beforeSend: service ? service.setModuleHeaders : null,
success: function(data) {
$.dnnAlert({ text: data.Result });
},
error: function (xhr, textStatus, errorThrown) {
if (xhr && xhr.responseText) {
$.dnnAlert({ text: eval('(' + xhr.responseText + ')').Message });
}
},
type: 'POST',
dataType: 'json',
contentType: "application/json"
});
});
};

window.__rgDataDivScrollTopPersistArray = [];
$(document).ajaxComplete(dnnInitCustomisedCtrls);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(saveRgDataDivScrollTop);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(dnnInitCustomisedCtrls);
$(dnnInitCustomisedCtrls);
handlerSendVerificationMailLink();
})(jQuery);