短信验证码校验 :param req: :param verify_code: :param phone: :return:
(req: Request, verify_code: str, phone: str)
| 136 | |
| 137 | |
| 138 | async 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 | |
| 157 | def send( |
no outgoing calls
no test coverage detected