Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: How to implement custom user system ? #2649

Closed
lizheming opened this issue Aug 4, 2024 Discussed in #2637 · 0 comments · Fixed by #2650
Closed

Q: How to implement custom user system ? #2649

lizheming opened this issue Aug 4, 2024 Discussed in #2637 · 0 comments · Fixed by #2650
Assignees
Labels
bug Something isn't working

Comments

@lizheming
Copy link
Collaborator

Discussed in https://github.com/orgs/walinejs/discussions/2637

Originally posted by yudaapratama July 28, 2024

Describe the bug | 问题描述

I try to implement a custom user system but I have an error

AssertionError [ERR_ASSERTION] [ERR_ASSERTION]: config.handle must be a function
    at new Model (/var/task/node_modules/.pnpm/[email protected]/node_modules/think-model/lib/model.js:25:5)
    at model (/var/task/node_modules/.pnpm/[email protected]/node_modules/think-model/index.js:32:22)
    at module.exports.injectModel [as model] (/var/task/node_modules/.pnpm/[email protected]/node_modules/think-model/index.js:47:22)
    at module.exports.count (/var/task/CustomModel.cjs:64:27)
    at module.exports.getCommentList (/var/task/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@waline/vercel/src/controller/comment.js:403:49)
    at module.exports.getAction (/var/task/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@waline/vercel/src/controller/comment.js:90:27)
    at /var/task/node_modules/.pnpm/[email protected]/node_modules/think-controller/index.js:55:32
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

this my index.cjs

const Application = require('@waline/vercel');
const CustomModel = require('./CustomModel.cjs');

module.exports = Application({
	env: 'development',
	model: (tableName) => {
		if(tableName !== 'Users') {
			return
		}
		return new CustomModel(tableName)
	},
  plugins: [],
  async postSave(comment) {
    // do what ever you want after comment saved
  },
});

i am trying to debug in file /lib/model.js in think-model when the model function is added, the config is empty.

what is the correct way to use a custom user system ?

Website URL | 问题网站

https://waline-server-test.vercel.app/

Where your waline deploy? | 服务部署在哪里?

Vercel (Default)

Where your comment data store? | 数据存储在哪里?

MySQL

@lizheming lizheming self-assigned this Aug 4, 2024
@lizheming lizheming added the bug Something isn't working label Aug 4, 2024
lizheming added a commit that referenced this issue Aug 4, 2024
@lizheming lizheming linked a pull request Aug 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant