链接点击一次后端跳转
This commit is contained in:
@@ -19,6 +19,10 @@ using Microsoft.AspNetCore.Http;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Application.Services;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using System.Linq;
|
||||
|
||||
namespace IRaCIS.Api.Controllers
|
||||
{
|
||||
@@ -188,17 +192,26 @@ namespace IRaCIS.Api.Controllers
|
||||
|
||||
|
||||
|
||||
//外部用户 邮件链接调用 以及跳转逻辑
|
||||
|
||||
[HttpGet("trialExternalUser/ExternalUserJoinTrial")]
|
||||
[HttpGet("User/UserRedirect")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> ExternalUserJoinTrial([FromServices] ITrialExternalUserService _trialExternalUserService, Guid trialId, Guid trialExternalUserId, string url)
|
||||
public async Task<IActionResult> UserRedirect([FromServices] IRepository<User> _userRepository, string url)
|
||||
{
|
||||
await _trialExternalUserService.UserConfirmJoinTrial(trialId, trialExternalUserId);
|
||||
|
||||
|
||||
var decodeUrl = System.Web.HttpUtility.UrlDecode(url);
|
||||
|
||||
var userId = decodeUrl.Substring(decodeUrl.IndexOf("UserId=") + "UserId=".Length , 36) ;
|
||||
|
||||
var token = decodeUrl.Substring(decodeUrl.IndexOf("access_token=") + "access_token=".Length);
|
||||
|
||||
var domainStrList = decodeUrl.Split("/").ToList().Take(3).ToList();
|
||||
|
||||
var errorUrl = domainStrList[0]+"//"+ domainStrList[2]+ "/error";
|
||||
|
||||
if (!await _userRepository.AnyAsync(t => t.Id == Guid.Parse(userId) && t.EmailToken == token && t.IsFirstAdd))
|
||||
{
|
||||
decodeUrl = errorUrl+ "?ErrorMessage=您的初始化链接已过期";
|
||||
}
|
||||
|
||||
return Redirect(decodeUrl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user