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

release 1.3.4 #259

Merged
merged 2 commits into from
Dec 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
'SELECT user_id, fcm_token FROM users WHERE fcm_token = ?';
const [selectRows] = await db.query(sqlSelect, [fcmToken]);

if (selectRows.length > 1) {
if (selectRows.length >= 1) {
const sqlUpdate = 'UPDATE users SET fcm_token = null WHERE user_id = ?';
const [updateRows] = await db.queryWithTransaction(sqlUpdate, [
selectRows[0].user_id,
Expand Down Expand Up @@ -54,15 +54,15 @@ module.exports = {

const checkPassword = bcrypt.compareSync(password, selectRows[0].password);

// fcm 토큰이 다른 유저에 존재한다면, null 처리
// fcm 토큰이 다른 유저에 존재한다면, 다른 유저를 null 처리
const sqlSelectByFcmToken =
'SELECT user_id, fcm_token FROM users WHERE fcm_token = ?';
const [selectFcmToken] = await db.query(sqlSelectByFcmToken, [fcmToken]);

console.log(selectFcmToken);
console.log(selectFcmToken.length >= 1);

if (selectFcmToken.length >= 1) {
if (
selectFcmToken.length >= 1 &&
selectFcmToken.user_id !== selectRows.user_id
) {
const sqlUpdate = 'UPDATE users SET fcm_token = null WHERE user_id = ?';
const [updateRows] = await db.queryWithTransaction(sqlUpdate, [
selectFcmToken[0].user_id,
Expand Down Expand Up @@ -100,7 +100,7 @@ module.exports = {

const [rows] = await db.query(sqlSelect, [email]);

if (rows.affectedRows < 1) {
if (rows.length > 1) {
throw new NotFound(ErrorMessage.unValidateUser);
}

Expand All @@ -122,7 +122,7 @@ module.exports = {

const [rows] = await db.query(sqlSelect, [userId]);

if (rows.affectedRows < 1) {
if (rows.length < 1) {
throw new NotFound(ErrorMessage.unValidateUser);
}

Expand Down
Loading