当前位置: 首页 > news >正文

常州做网站价位网络营销渠道策略有哪些

常州做网站价位,网络营销渠道策略有哪些,做收益的网站多少钱,情趣用品网站建设1.需求 为了让用户的密码更加保密 我们在md5 之前 在加一个随机数 用java 的说法 叫做 加盐算法 2.代码 //H5注册async H5Register(register) {if (!register.phone ||!register.password ||!register.confirmPassword ||!register.yzmCode ||!register.registerCode) {thr…

1.需求 

为了让用户的密码更加保密 

我们在md5 之前 在加一个随机数 用java 的说法 叫做 加盐算法

2.代码

 //H5注册async H5Register(register) {if (!register.phone ||!register.password ||!register.confirmPassword ||!register.yzmCode ||!register.registerCode) {throw new CoolCommException('参数不能为空~');}const phoneRegex = /^1[3-9]\d{9}$/; // 手机号码的正则表达式if (!phoneRegex.test(register.phone)) {throw new CoolCommException('手机号码格式不正确~');}if (register.password !== register.confirmPassword) {throw new CoolCommException('两次密码不一致');}const inviteCode = await this.businessUserEntity.findOneBy({inviteCode: register.registerCode,});if (!inviteCode) {throw new CoolCommException('导师不存在~');}const checkV = await this.captchaCheckByH5(register.yzmCode);if (checkV) {const user = await this.businessStudentEntity.findOneBy({phone: register?.phone,});if (user) {throw new CoolCommException('账户已存在~');}const salt = this.generatePasswordCode();await this.businessStudentEntity.save({phone: register.phone,password: md5(register.password + salt).toUpperCase(),membershipLevel: 0,balance: 0,userId: inviteCode.id,randomStr: salt,});return 1;} else {throw new CoolCommException('验证码不正确~');}}

 //生成加盐密码public generatePasswordCode() {// const hmac = crypto.createHmac('sha256', '1234567890');// hmac.update(password.toString());// const hash = hmac.digest('hex');// const code = hash.substring(0, 6).toUpperCase();// return code;let chars = 'ABCDEFGHJKMNPQRSTWXYZ1234567890';/****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/let maxPos = chars.length;var code = '';for (let i = 0; i < 6; i++) {code += chars.charAt(Math.floor(Math.random() * maxPos));}return code.toString();}

3 登录验证 

为了适配之前的纯md5 方式

  // H5 登录async H5Login(login) {if (!login.password || !login.phone) {throw new CoolCommException('账户或者密码不能为空~');}let user;// 尝试使用直接MD5加密的密码进行验证const userByDirectMd5 = await this.businessStudentEntity.findOneBy({phone: login.phone,password: md5(login.password),});// 如果没有找到,尝试使用带有随机字符串的加密方式if (!userByDirectMd5) {const userInfo = await this.businessStudentEntity.findOneBy({phone: login.phone,});if (!userInfo) {// 手机号不存在,直接返回错误throw new CoolCommException('账户不存在或密码不正确~');}const userByRandomStrMd5 = await this.businessStudentEntity.findOneBy({phone: login.phone,password: md5(login.password + userInfo.randomStr).toUpperCase(),});if (!userByRandomStrMd5) {// 密码不正确throw new CoolCommException('账户不存在或密码不正确~');}// 这里可以设置 user 为使用随机字符串加密方式找到的用户user = userByRandomStrMd5;} else {// 这里设置 user 为使用直接MD5加密方式找到的用户user = userByDirectMd5;}// 检查账户是否启用if (user.isEnabled == 0) {throw new CoolCommException('账户无权限,请联系客服开通~');}// 生成和缓存JWT令牌const { expire, refreshExpire } = this.coolConfig.jwt.token;const result = {expire,token: await this.generateTokenClient(user, expire),refreshExpire,refreshToken: await this.generateTokenClient(user, refreshExpire, true),};// 缓存令牌await this.cacheManager.set(`business:client:token:${user.id}`,result.token,{ ttl: expire });await this.cacheManager.set(`business:client:token:refresh:${user.id}`,result.refreshToken,{ ttl: refreshExpire });return result;}

http://www.ritt.cn/news/26756.html

相关文章:

  • 网站运营团队各岗位的职责是什么千锋教育的官网
  • 自定义优定软件网站建设重庆百度关键词优化软件
  • 建设网站用什么语言好app推广好做吗
  • 自学编程从哪里开始学微博seo营销
  • 动漫网站建设意义百度一下主页官网
  • 怎么做网页文件打开别的网站深圳网站seo哪家快
  • 进入网络管理的网站百度提交入口网址
  • web.py做网站宝塔建站系统
  • 网站文章更新要求xp优化大师
  • 如何注销网站备案负责人百度网络推广
  • 网站没备案做阿里妈妈网站建设排名优化
  • 网站建设公司上海做网站公司哪家好百度pc端入口
  • 网站建设 经营范围seo网站分析报告
  • 深圳网站备案查询设计网站大全
  • 营销网站建设流程图windows优化大师手机版
  • 台州市建设监理协会网站贵阳网络推广排名
  • 网站留言板块怎么做seo前线
  • 专业的河南网站建设公司网上做广告怎么收费
  • wordpress 宝塔加速seo是什么车
  • jsp网站开发环境配置百度服务商
  • asp.net做网站实例google广告投放
  • 网站频道策划龙岗网站制作
  • 网站要和别人做api 链接信息如何优化上百度首页
  • 网站上的搜索怎么做在线培训平台哪家好
  • 网站开发天津网络营销学什么内容
  • 可做分析图的地图网站国内最近发生的重大新闻
  • 网站分析如何在其他平台做推广
  • 建立自己的网站需要多少钱百度总部地址
  • 调研园区网站建设工作推广信息发布平台
  • 手机网站模板html5百度站长统计