MCPcopy Create free account
hub / github.com/binkuolo/fastapi / check_code

Function check_code

api/extends/sms.py:138–154  ·  view source on GitHub ↗

短信验证码校验 :param req: :param verify_code: :param phone: :return:

(req: Request, verify_code: str, phone: str)

Source from the content-addressed store, hash-verified

136
137
138async def check_code(req: Request, verify_code: str, phone: str):
139 """
140 短信验证码校验
141 :param req:
142 :param verify_code:
143 :param phone:
144 :return:
145 """
146 # 获取redis中的验证码
147 redis: Redis = await req.app.state.code_cache
148 code = await redis.get(f"code_{phone}")
149 # 比对验证码
150 if code and verify_code == code:
151 await redis.delete(f"code_{phone}")
152 return True
153 # 获取缓存中验证码
154 return False
155
156
157def send(

Callers 2

account_loginFunction · 0.90
update_user_infoFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected