liufumingren 08d9ea103b chore(微信): 移除自建微信授权表 wechat_oauth / wechat_mp_accounts
微信侧接入已统一到登录网关,自建的两套都下线:

- 删除表:wechat_oauth(自建公众号网页授权 + 运维手工维护的绑定关系)、
  wechat_mp_accounts(小程序 code2Session 一键登录);迁移 20261029100000(up 删表、down 按原结构重建)
- 删除代码:service/{wechat,wechat_mp}.js、controller/web/wechat_mp.js、model/{wechat_oauth,wechat_mp_account}.js、
  service/user.js#findByOpenid、user 模型的 hasMany WechatOauth、公众号 OAuth 回调与 /api/web/auth/wechat/*
- 删除环境变量:WECHAT_APPID/SECRET/REDIRECT_URI/API_BASE、WX_MP_*(config.wechat 只剩设备扫码登录用到的串码/二维码参数)
- 小程序:去掉「微信一键登录」tab,只留账号密码登录(删 utils/wechat.ts 与 wechatLogin 调用)
- sql/schema.sql 同步去掉 wechat_oauth 建表

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-29 17:20:28 +08:00

40 lines
1.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 用户表模型(users)
*
* 通用约定在 config/config.default.js 的 sequelize.define 里配置:
* freezeTableName / underscored / created_at / updated_at,
* 这里通过 paranoid: true 开启软删除(对应 deleted_at 字段)。
*/
module.exports = (app) => {
const { BIGINT, STRING, TINYINT, DATE } = app.Sequelize;
const User = app.model.define('user', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
username: { type: STRING(64), comment: '登录名' },
nickname: { type: STRING(64), allowNull: false, defaultValue: '', comment: '昵称' },
email: { type: STRING(128), comment: '邮箱(可选,可作登录账号)' },
avatar: { type: STRING(255), allowNull: false, defaultValue: '', comment: '头像地址' },
phone: { type: STRING(20), comment: '手机号' },
// 密码哈希(bcrypt),接口与模板都不外泄:查询时会显式 exclude
passwordHash: { type: STRING(100), comment: '密码哈希(bcrypt)' },
// 最近一次设置/重置密码的时间:签发早于它的 user JWT 立即失效(见 middleware/api_auth.js)
passwordChangedAt: { type: DATE, comment: '最近一次设置/重置密码的时间' },
gender: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 0, comment: '性别:0未知 1男 2女' },
status: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '状态:1正常 0禁用' },
remark: { type: STRING(255), comment: '备注' },
lastLoginAt: { type: DATE, comment: '最近登录时间' },
}, {
tableName: 'users',
paranoid: true,
comment: '用户表',
});
User.associate = function() {
app.model.User.hasMany(app.model.Scanner, { foreignKey: 'user_id', as: 'scanners' });
};
return User;
};