async def authentication_register( register_filters: RegisterFilters, db: Session = Depends(get_db), ) -> AuthenticationRegisterInResponse: """ 获取接口调用凭证 <br/> email: 获取凭证的邮箱地址 凭证会以邮件方式发往改邮箱 """ logger.info(f"received parameters, register_filters:{register_filters}") bloom_filter = BloomFilterUtils() email = EmailUtils() if not register_filters or not email.check_email(register_filters.email): raise CustomException(EMAIL_ERROR, msg_dict={"error": "format is incorrect"}) # 邮箱已认证 if bloom_filter.contains(register_filters.email) or CovidUser.get_user( db=db, condition={CovidUser.email.key: register_filters.email}): raise CustomException(EMAIL_ERROR, msg_dict={"error": "email has been certified"}) # 发送 token 信息 token = FishMD5.hmac_md5(register_filters.email, str(get_time_uuid())) send_status = email.send_mail(EMAIL_CONTENT.format(_Token=token), register_filters.email) if not send_status: raise CustomException(EMAIL_ERROR, msg_dict={"error": "failed to send"}) # 保存,记录邮箱信息 CovidUser.add_user(db=db, email=register_filters.email, token=token) bloom_filter.add(register_filters.email) return AuthenticationRegisterInResponse(data={"status": True})
def hmac_md5(s, salt): from fishbase.fish_crypt import FishMD5 show_deprecation_warn('GetMD5.hmac_md5', 'fish_crypt.FishMD5.hmac_md5') return FishMD5.hmac_md5(s, salt)