MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / SendSMS

Method SendSMS

internal/api/user.go:157–175  ·  view source on GitHub ↗

SendSMS 发送短信验证码

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

155
156// SendSMS 发送短信验证码
157func (uh *UserHandler) SendSMS(ctx *gin.Context) {
158 var req req.SMSReq
159 if err := ctx.ShouldBindJSON(&req); err != nil {
160 apiresponse.ErrorWithMessage(ctx, "无效的请求参数")
161 return
162 }
163
164 if !utils.IsValidNumber(req.Number) {
165 apiresponse.ErrorWithMessage(ctx, "无效的手机号码")
166 return
167 }
168
169 if err := uh.smsProducer.ProduceSMSCode(ctx, sms.SMSCodeEvent{Number: req.Number}); err != nil {
170 apiresponse.ErrorWithMessage(ctx, "发送短信验证码失败")
171 return
172 }
173
174 apiresponse.Success(ctx)
175}
176
177// ChangePassword 修改密码
178func (uh *UserHandler) ChangePassword(ctx *gin.Context) {

Callers

nothing calls this directly

Calls 4

ErrorWithMessageFunction · 0.92
IsValidNumberFunction · 0.92
SuccessFunction · 0.92
ProduceSMSCodeMethod · 0.65

Tested by

no test coverage detected