feat: remove supabase
This commit is contained in:
@@ -16,6 +16,7 @@ type UserData = {
|
||||
export class User extends Model {
|
||||
declare id: string;
|
||||
declare username: string;
|
||||
declare nickname: string; // 昵称
|
||||
declare password: string;
|
||||
declare salt: string;
|
||||
declare needChangePassword: boolean;
|
||||
@@ -26,29 +27,20 @@ export class User extends Model {
|
||||
declare orgId: string;
|
||||
declare email: string;
|
||||
declare avatar: string;
|
||||
declare supaId: string;
|
||||
tokenUser: any;
|
||||
setTokenUser(tokenUser: any) {
|
||||
this.tokenUser = tokenUser;
|
||||
}
|
||||
/**
|
||||
* uid 是用于 orgId 的用户id
|
||||
* uid 是用于 orgId 的用户id 真实用户的id
|
||||
* @param uid
|
||||
* @returns
|
||||
*/
|
||||
async createToken(uid?: string) {
|
||||
const { id, username, type, supaId } = this;
|
||||
const { id, username, type } = this;
|
||||
const expireTime = 60 * 60 * 24 * 7; // 7 days
|
||||
const now = new Date().getTime();
|
||||
let supa = {};
|
||||
if (supaId) {
|
||||
supa = {
|
||||
aud: 'authenticated',
|
||||
role: 'authenticated',
|
||||
sub: supaId,
|
||||
};
|
||||
}
|
||||
const token = await createToken({ id, username, uid, type, ...supa }, config.tokenSecret);
|
||||
const token = await createToken({ id, username, uid, type }, config.tokenSecret);
|
||||
return { token, expireTime: now + expireTime };
|
||||
}
|
||||
static async verifyToken(token: string) {
|
||||
@@ -155,6 +147,12 @@ User.init(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
// 用户名或者手机号
|
||||
// 创建后避免修改的字段,当注册用户后,用户名注册则默认不能用手机号
|
||||
},
|
||||
nickname: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING,
|
||||
@@ -165,7 +163,7 @@ User.init(
|
||||
allowNull: true,
|
||||
},
|
||||
avatar: {
|
||||
type: DataTypes.STRING,
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
},
|
||||
salt: {
|
||||
@@ -173,7 +171,7 @@ User.init(
|
||||
allowNull: true,
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
type: DataTypes.TEXT,
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.STRING,
|
||||
@@ -185,9 +183,6 @@ User.init(
|
||||
orgId: {
|
||||
type: DataTypes.UUID,
|
||||
},
|
||||
supaId: {
|
||||
type: DataTypes.UUID,
|
||||
},
|
||||
needChangePassword: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
@@ -199,7 +194,7 @@ User.init(
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: 'cf_user',
|
||||
tableName: 'cf_user', // codeflow user
|
||||
paranoid: true,
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user