Beispiel #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                throw new KuArgNullException();
            }

            await _service.AddAsync(Dto);

            return(Json(true));
        }
Beispiel #2
0
        public async Task <IActionResult> OnPostSendCodeAsync([Required] string mobile)
        {
            //取得用户信息
            var user = await _service.GetOneAsync(new UserSearch { Mobile = mobile });

            if (user != null)
            {
                throw new KuException("当前手机号已被注册!");
            }

            //生成随机数
            var code = CodeHelper.Create(6, CodeLetterType.Number);

            //保存到缓存
            await _cache.SetAsync(string.Format(CacheKeyDefinition.SmsVerifyCode_Register, mobile), code, TimeSpan.FromMinutes(30));

            //发送短信
            await _smsService.AddAsync(mobile, "vcode", new { code });

            return(Json(true));
        }
Beispiel #3
0
        public async Task <IActionResult> DoAdd(SmsDto model)
        {
            await _service.AddAsync(model);

            return(JsonData(true));
        }