src/ZKEACMS/Notification/NotifyService.cs
(完整代码) 1KB/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using System;
using System.Collections.Generic;
using System.Text;
using Easy.Modules.User.Models;
using Easy.Notification;
using Microsoft.AspNetCore.Http;
using ZKEACMS.Notification.ViewModels;
using Microsoft.AspNetCore.DataProtection;
using Easy;
namespace ZKEACMS.Notification
{
public class NotifyService : INotifyService
{
private readonly INotificationManager _notificationManager;
private readonly IHostOptionProvider _hostOptionProvider;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly ILocalize _localize;
public NotifyService(INotificationManager notificationManager,
IHostOptionProvider hostOptionProvider,
IDataProtectionProvider dataProtectionProvider,
ILocalize localize)
{
_notificationManager = notificationManager;
_hostOptionProvider = hostOptionProvider;
_dataProtectionProvider = dataProtectionProvider;
_localize = localize;
}
public void ResetPassword(UserEntity user)
{
var dataProtector = _dataProtectionProvider.CreateProtector("ResetPassword");
_notificationManager.Send(new RazorEmailMessage
{
Subject = _localize.Get("Reset password"),
To = new string[] { user.Email },
Model = new ResetPasswordViewModel
{
Link = $"{_hostOptionProvider.GetOrigin()}/Account/Reset?token={user.ResetToken}&pt={dataProtector.Protect(user.ResetToken)}"
},
TemplatePath = "~/EmailTemplates/ResetPassword.cshtml"
});
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。