Skip to content

Q: 关于 hook || Q: About hooks #2096

Closed Answered by lizheming
felixesintot asked this question in Q&A
Discussion options

You must be logged in to vote
  1. 昵称和邮箱不为空可直接配置见文档 https://waline.js.org/reference/client/props.html#requiredmeta
  2. 注册用户昵称不可重复 demo,具体可参照这个代码逻辑自己调试改下
// index.js
const Waline = require('@waline/vercel');

module.exports = Waline({
  plugins: [
    {
      middlewares: [
        async (ctx, next) => {
          if(ctx.method !== 'POST' || ctx.url !== '/api/user') {
            return next();
          }
      
         const { storage } = think.config();
          const userModel = ctx.services(`storage/${storage}`, 'Users');
          const { display_name } = ctx.post();

          const users = await userModel.where({ display_name }).select();
          if (think.isEmpty(users)) {
              ctx.status = 500;

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@lizheming
Comment options

@felixesintot
Comment options

@felixesintot
Comment options

@felixesintot
Comment options

@felixesintot
Comment options

Answer selected by felixesintot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants