链接点击一次后端跳转
							parent
							
								
									144f53e809
								
							
						
					
					
						commit
						a261605bde
					
				| 
						 | 
				
			
			@ -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);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -390,7 +390,6 @@
 | 
			
		|||
            传入参数记录ID
 | 
			
		||||
            </summary>
 | 
			
		||||
            <param name="SignInfo"></param>
 | 
			
		||||
            <param name="response"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:IRaCIS.Core.Application.Service.Inspection.InspectionService.CompletedSign(System.Guid,IRaCIS.Core.Infrastructure.Extention.IResponseOutput)">
 | 
			
		||||
| 
						 | 
				
			
			@ -971,7 +970,6 @@
 | 
			
		|||
            发送验证码
 | 
			
		||||
            </summary>
 | 
			
		||||
            <param name="userInfo"></param>
 | 
			
		||||
            <param name="_mailVerificationService"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:IRaCIS.Core.Application.Contracts.TrialSiteSurveyService.VerifySendCode(IRaCIS.Core.Application.Contracts.LoginDto,IRaCIS.Core.Application.Auth.ITokenService)">
 | 
			
		||||
| 
						 | 
				
			
			@ -2354,13 +2352,6 @@
 | 
			
		|||
        <member name="M:IRaCIS.Application.Services.UserService.SendVerificationCode(System.String)">
 | 
			
		||||
            <summary>发送验证码  修改邮箱(已经登陆修改) New </summary>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:IRaCIS.Application.Services.UserService.VerifyCanInitSetUserNameAndPwd(System.Guid)">
 | 
			
		||||
            <summary>
 | 
			
		||||
             Result  为true 的时候 允许提交设置
 | 
			
		||||
            </summary>
 | 
			
		||||
            <param name="userId"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:IRaCIS.Application.Services.UserService.ResetPassword(System.Guid)">
 | 
			
		||||
            <summary>
 | 
			
		||||
            重置密码为 默认密码
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
 | 
			
		||||
        Task AnolymousSendEmailForResetAccount(string emailAddress, int verificationCode);
 | 
			
		||||
 | 
			
		||||
        Task AddUserSendEmailAsync(Guid userId, string routeUrl);
 | 
			
		||||
        Task AddUserSendEmailAsync(Guid userId, string baseUrl, string routeUrl);
 | 
			
		||||
 | 
			
		||||
        Task AdminResetPwdSendEmailAsync(Guid userId);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -253,8 +253,9 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
        //添加用户发送邮件
 | 
			
		||||
        public async Task AddUserSendEmailAsync(Guid userId, string routeUrl)
 | 
			
		||||
        public async Task AddUserSendEmailAsync(Guid userId, string baseUrl, string routeUrl)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            var sysUserInfo = (await _userRepository.Where(t => t.Id == userId).Include(t => t.UserTypeRole).FirstOrDefaultAsync()).IfNullThrowException();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -281,6 +282,10 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
            await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token });
 | 
			
		||||
 | 
			
		||||
            routeUrl = routeUrl + "?UserId=" + sysUserInfo.Id + "&Email=" + sysUserInfo.EMail + "&UserName=" + sysUserInfo.UserName + "&UserType=" + sysUserInfo.UserTypeRole.UserTypeShortName + "&access_token=" + token;
 | 
			
		||||
         
 | 
			
		||||
            var domain=baseUrl.Substring(0,baseUrl.IndexOf("/login"));
 | 
			
		||||
 | 
			
		||||
            var redirectUrl = $"{domain}/api/User/UserRedirect?url={ System.Web.HttpUtility.UrlEncode(routeUrl) }";
 | 
			
		||||
 | 
			
		||||
            using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -291,7 +296,7 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
                   sysUserInfo.FullName,
 | 
			
		||||
                   sysUserInfo.UserName,
 | 
			
		||||
                   sysUserInfo.UserTypeRole.UserTypeShortName,
 | 
			
		||||
                    routeUrl
 | 
			
		||||
                    redirectUrl
 | 
			
		||||
                    );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -389,6 +394,10 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
 | 
			
		||||
                var routeUrl = rootUrl + "?UserId=" + sysUserInfo.Id + "&Email=" + sysUserInfo.EMail + "&UserName=" + sysUserInfo.UserName + "&UserType=" + sysUserInfo.UserTypeRole.UserTypeShortName + "&access_token=" + token;
 | 
			
		||||
 | 
			
		||||
                var domain = baseUrl.Substring(0, baseUrl.IndexOf("/login"));
 | 
			
		||||
 | 
			
		||||
                var redirectUrl = $"{domain}/api/User/UserRedirect?url={ System.Web.HttpUtility.UrlEncode(routeUrl) }";
 | 
			
		||||
 | 
			
		||||
                builder.HtmlBody = string.Format(templateInfo,
 | 
			
		||||
                    sysUserInfo.FullName,
 | 
			
		||||
                    trialInfo.ExperimentName,
 | 
			
		||||
| 
						 | 
				
			
			@ -396,7 +405,7 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
                    trialInfo.TrialCode,
 | 
			
		||||
                    sysUserInfo.UserName,
 | 
			
		||||
                    sysUserInfo.UserTypeRole.UserTypeShortName,
 | 
			
		||||
                    sysUserInfo.IsFirstAdd ? routeUrl : baseUrl
 | 
			
		||||
                    sysUserInfo.IsFirstAdd ? redirectUrl : baseUrl
 | 
			
		||||
                    );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -443,8 +452,12 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
            {
 | 
			
		||||
                var templateInfo = SourceReader.ReadToEnd();
 | 
			
		||||
 | 
			
		||||
                var domain = baseUrl.Substring(0, baseUrl.IndexOf("/login"));
 | 
			
		||||
 | 
			
		||||
                var routeUrl = rootUrl + "?UserId=" + sysUserInfo.Id + "&Email=" + sysUserInfo.EMail + "&UserName=" + sysUserInfo.UserName + "&UserType=" + sysUserInfo.UserTypeRole.UserTypeShortName + "&access_token=" + token;
 | 
			
		||||
 | 
			
		||||
                var redirectUrl = $"{domain}/api/User/UserRedirect?url={ System.Web.HttpUtility.UrlEncode(routeUrl) }";
 | 
			
		||||
 | 
			
		||||
                builder.HtmlBody = string.Format(templateInfo,
 | 
			
		||||
                    sysUserInfo.FullName,
 | 
			
		||||
                    trialInfo.ExperimentName,
 | 
			
		||||
| 
						 | 
				
			
			@ -452,7 +465,7 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
                    trialInfo.TrialCode,
 | 
			
		||||
                   sysUserInfo.UserName,
 | 
			
		||||
                    sysUserInfo.UserTypeRole.UserTypeShortName,
 | 
			
		||||
                   sysUserInfo.IsFirstAdd ? routeUrl : baseUrl
 | 
			
		||||
                   sysUserInfo.IsFirstAdd ? redirectUrl : baseUrl
 | 
			
		||||
                    );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -158,7 +158,6 @@ namespace IRaCIS.Core.Application.Service.Inspection
 | 
			
		|||
        /// 传入参数记录ID
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="SignInfo"></param>
 | 
			
		||||
        /// <param name="response"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<Guid> RecordSing(SignDTO SignInfo)
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -159,7 +159,7 @@ namespace IRaCIS.Application.Contracts
 | 
			
		|||
 | 
			
		||||
    public class UserCommand : UserInfo
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        public string BaseUrl { get; set; } = string.Empty;
 | 
			
		||||
        public string RouteUrl { get; set; } = string.Empty;
 | 
			
		||||
 | 
			
		||||
        //public string FirstName { get; set; }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -199,26 +199,23 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
            return ResponseOutput.Ok();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///  Result  为true 的时候 认为链接没有失效
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="userId"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpGet]
 | 
			
		||||
        public async Task<IResponseOutput> VerifyCanInitSetUserNameAndPwd(Guid userId)
 | 
			
		||||
        {
 | 
			
		||||
            return ResponseOutput.Ok(await _userRepository.AnyAsync(t => t.Id == userId && t.EmailToken == _userInfo.UserToken && t.IsFirstAdd));
 | 
			
		||||
        }
 | 
			
		||||
        ///// <summary>
 | 
			
		||||
        /////  Result  为true 的时候 认为链接没有失效
 | 
			
		||||
        ///// </summary>
 | 
			
		||||
        ///// <param name="userId"></param>
 | 
			
		||||
        ///// <returns></returns>
 | 
			
		||||
        //[HttpGet]
 | 
			
		||||
        //public async Task<IResponseOutput> VerifyCanInitSetUserNameAndPwd(Guid userId)
 | 
			
		||||
        //{
 | 
			
		||||
        //    return ResponseOutput.Ok(await _userRepository.AnyAsync(t => t.Id == userId && t.EmailToken == _userInfo.UserToken && t.IsFirstAdd));
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        [HttpGet]
 | 
			
		||||
        public async Task<IResponseOutput> InitSetUserNameAndPwd(Guid userId, string newUserName, string newPWd)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (!await _userRepository.AnyAsync(t => t.Id == userId && t.EmailToken==_userInfo.UserToken && t.IsFirstAdd))
 | 
			
		||||
            {
 | 
			
		||||
                return ResponseOutput.NotOk("您的初始化链接已过期");
 | 
			
		||||
            }
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            await VerifyUserPwdAsync(userId, newPWd);
 | 
			
		||||
| 
						 | 
				
			
			@ -489,7 +486,7 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
 | 
			
		||||
            var success = await _userRepository.SaveChangesAsync();
 | 
			
		||||
 | 
			
		||||
            await _mailVerificationService.AddUserSendEmailAsync(saveItem.Id, userAddModel.RouteUrl);
 | 
			
		||||
            await _mailVerificationService.AddUserSendEmailAsync(saveItem.Id, userAddModel.BaseUrl, userAddModel.RouteUrl);
 | 
			
		||||
 | 
			
		||||
            return ResponseOutput.Result(success, new UserAddedReturnDTO { Id = saveItem.Id, UserCode = saveItem.UserCode });
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,7 +52,6 @@ namespace IRaCIS.Core.Application.Contracts
 | 
			
		|||
        /// 发送验证码
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="userInfo"></param>
 | 
			
		||||
        /// <param name="_mailVerificationService"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [AllowAnonymous]
 | 
			
		||||
        public async Task<IResponseOutput> SendVerifyCode(SiteSurveySendVerifyCode userInfo)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue