node-egg-w

1.0.0 • Public • Published

keywrds

To get type suggestions for instance variables (this is not needed for composition API), create a new file called shims-vue-recaptcha-v3.d.ts and put the following inside it:

TypeScript + Vue 3 To use this package you only need a valid site key for your domain, which you can easily get here.

$ third party

## $ //back/config/default

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
    security: {
      csrf: false
    },
    gitee: {
      client_id: 'youid',
      client_secret: 'you',
      redirect_uri: 'http://localhost:3000/login'
    },

A simple and easy to use reCAPTCHA (v3 only) library for Vue based on reCAPTCHA-v3.

The latest version of this package supports Vue 3! See here for Vue 2 usage.

$ appControllerUser

app/controller/user

async registry() {
        const { ctx } = this;
        const { name, pwd, phone, eamil, sex } = ctx.request.body;
        ctx.validate(createRule, ctx.request.body);
        let user = await ctx.service.user.getuser(name);
        if (user) {
            ctx.body = {
                code: 3,
               
            }
            return;
        }
        let res = await ctx.service.user.registry({ ...ctx.request.body, pwd: ctx.helper.cryptopwd(pwd), avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png' });
        if (res.affectedRows == 1) {
            ctx.body = {
                code: 0,

            }
        } else {
            ctx.body = {
                code: 1,
                mes: 
            }
        }
    }

TypeScript + Vue 3 To get type suggestions for instance variables (this is not needed for composition API), create a new file called shims-vue-recaptcha-v3.d.ts and put the following inside it:

controllerUser

app/controller/user

async login() {
        const { ctx } = this;
        const { name, pwd, captcha } = ctx.request.body;
        ctx.validate(createLogin, ctx.request.body);
        if (ctx.session.captcha.toUpperCase() !== captcha.toUpperCase()) {
            ctx.body = {
                code: 2,
                mes: 
            }
            return;
        }
        let user = await ctx.service.user.getuser(name);
        if (!user) {
            ctx.body = {
                code: 3,
            }
            return;
        }

        let res = await ctx.service.user.login({ name, pwd: ctx.helper.cryptopwd(pwd) });
        if (res.length > 0) {
            ctx.body = {
                code: 0,
                token: ctx.helper.gettoken({ name: res[0].name, id: res[0].id }),
                mes: 
            }
        } else {
            ctx.body = {
                code: 1,
                mes: 
            }
        }

    }

$ packjson

packjson

{
  "name": "back_end",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "egg": {
    "declarations": true
  },
  "dependencies": {
    "axios": "^0.21.4",
    "egg": "^2.15.1",
    "egg-mysql": "^3.0.0",
    "egg-oss": "^2.0.0",
    "egg-scripts": "^2.11.0",
    "egg-validate": "^2.0.2",
    "jsonwebtoken": "^8.5.1",
    "svg-captcha": "^1.4.0"
  },
  "devDependencies": {
    "autod": "^3.0.1",
    "autod-egg": "^1.1.0",
    "egg-bin": "^4.11.0",
    "egg-ci": "^1.11.0",
    "egg-mock": "^3.21.0",
    "eslint": "^5.13.0",
    "eslint-config-egg": "^7.1.0"
  },
  "engines": {
    "node": ">=10.0.0"
  },
  "scripts": {
    "start": "egg-scripts start --daemon --title=egg-server-back_end",
    "stop": "egg-scripts stop --title=egg-server-back_end",
    "dev": "egg-bin dev",
    "debug": "egg-bin debug",
    "test": "npm run lint -- --fix && npm run test-local",
    "test-local": "egg-bin test",
    "cov": "egg-bin cov",
    "lint": "eslint .",
    "ci": "npm run lint && npm run cov",
    "autod": "autod"
  },
  "ci": {
    "version": "10"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "",
  "license": "MIT"
}




Readme

Keywords

none

Package Sidebar

Install

npm i node-egg-w

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

4.37 kB

Total Files

3

Last publish

Collaborators

  • ghjk