사용자 로직 수정

This commit is contained in:
2025-06-09 23:15:42 +09:00
parent 7e1bbcede0
commit 9764a96918
4 changed files with 75 additions and 44 deletions
+9 -1
View File
@@ -1,6 +1,7 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const bcrypt = require('bcrypt');
const { encrypt, decrypt } = require('../utils/encryption');
const User = sequelize.define('User', {
id: {
@@ -32,7 +33,14 @@ const User = sequelize.define('User', {
validate: {
isEmail: true
},
comment: '이메일'
comment: '이메일 (암호화됨)',
get() {
const rawValue = this.getDataValue('email');
return rawValue ? decrypt(rawValue) : null;
},
set(value) {
this.setDataValue('email', value ? encrypt(value) : null);
}
},
role: {
type: DataTypes.ENUM('admin', 'clubadmin', 'user'),