Пример #1
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override async Task <LoginResult> Login(LoginForm input, ServerCallContext context)
        {
            var hash = Configuration["Customization:PwdKey"];

            var user = await _mediator.Send(new LoginInput()
            {
                IpAddress   = input.IpAddress,
                Password    = EncryptUtil.AESEncrypt(input.Password, hash),
                PhoneNumber = input.PhoneNumber
            }, context.CancellationToken);

            var expired = DateTime.Now.AddMinutes(120);

            var claims = new Claim[] {
                new Claim(ClaimTypes.Name, user.UserName),
                new Claim(ClaimTypes.Sid, user.UserId.ToString()),
                new Claim("Ip", input.IpAddress),
                new Claim("TenantId", user.TenantId.ToString()),   //租户
                new Claim(ClaimTypes.MobilePhone, user.PhoneNumber)
            };

            return(new LoginResult()
            {
                Token = JsonConvert.SerializeObject(_tokenBuilder.BuildJwtToken(claims, DateTime.UtcNow, expired))
            });
        }
Пример #2
0
        public async Task <BizResult <string> > Register(CreateMemberCommand dto)
        {
            var hash = configuration["Customization:PwdKey"];

            dto.Password = EncryptUtil.AESEncrypt(dto.Password, hash);
            await _mediator.Send(dto, HttpContext.RequestAborted);

            return(new BizResult <string>("注册成功"));
        }