Skip to content

Commit

Permalink
050 - 회원탈퇴 & 로그인 규칙
Browse files Browse the repository at this point in the history
  • Loading branch information
moosin76 committed Dec 3, 2021
1 parent 9a35ea5 commit e03cd4d
Show file tree
Hide file tree
Showing 39 changed files with 79 additions and 18 deletions.
4 changes: 2 additions & 2 deletions server/api/_model/memberModel.js
Expand Up @@ -105,7 +105,7 @@ const memberModel = {

// 이미지 처리
delete payload.mb_image;
const mb_photo = payload.mb_photo;
const mb_photo = payload.mb_photo || '';
const photoPathInfo = path.parse(mb_photo);
const oldName = photoPathInfo.name;
const oldFile = `${MEMBER_PHOTO_PATH}/${oldName}.jpg`;
Expand All @@ -115,7 +115,7 @@ const memberModel = {
if(deleteImage || (req.files && req.files.mb_image)) {
payload.mb_photo = '';
try {
fs.unlink(oldFile);
fs.unlinkSync(oldFile);
const cacheDir = fs.readdirSync(cachePath);
for(const p of cacheDir) {
if(p.startsWith(oldName)) {
Expand Down
60 changes: 45 additions & 15 deletions server/plugins/passport.js
Expand Up @@ -6,6 +6,7 @@ const memberModel = require('../api/_model/memberModel');
const GoogleStrategy = require('passport-google-oauth2').Strategy;
const KakaoStrategy = require('passport-kakao').Strategy;
const NaverStrategy = require('passport-naver').Strategy;
const { LV } = require('../../util/level');

const {
GOOGLE_CLIENT_ID,
Expand All @@ -17,6 +18,19 @@ const {
NAVER_CLIENT_SECRET,
} = process.env;

function loginRules(member) {
// 탈퇴회원
if(member.mb_leave_at) {
return '탈퇴 회원입니다.';
}
switch(member.mb_level) {
case LV.AWAIT :
return '대기 회원입니다.';
case LV.BLOCK :
return '차단 회원입니다.';
}
}

module.exports = (app) => {
app.use(passport.initialize());

Expand All @@ -29,6 +43,10 @@ module.exports = (app) => {
try {
mb_password = jwt.generatePassword(mb_password);
const member = await memberModel.getMemberBy({ mb_id, mb_password });
const msg = loginRules(member);
if(msg) {
return done(null, null, msg);
}
return done(null, member);
} catch (e) {
console.log(e.message);
Expand All @@ -48,13 +66,17 @@ module.exports = (app) => {
if (profile && profile.id) {
// const member = await memberModel.loginGoogle(request, profile);
const data = {
id : profile.id,
provider : profile.provider,
email : profile.email,
nickname : profile.displayName,
image : profile.picture,
id: profile.id,
provider: profile.provider,
email: profile.email,
nickname: profile.displayName,
image: profile.picture,
};
const member = await memberModel.loginSocial(request, data);
const msg = loginRules(member);
if(msg) {
return done(null, null, msg);
}
done(null, member);
} else {
done('로그인 실패', null);
Expand All @@ -74,13 +96,17 @@ module.exports = (app) => {
if (profile && profile.id) {
// const member = await memberModel.loginKakao(request, profile);
const data = {
id : profile.id,
provider : profile.provider,
email : profile._json.kakao_account.email,
nickname : profile._json.kakao_account.profile.nickname,
image : profile._json.kakao_account.profile.thumbnail_image_url,
id: profile.id,
provider: profile.provider,
email: profile._json.kakao_account.email,
nickname: profile._json.kakao_account.profile.nickname,
image: profile._json.kakao_account.profile.thumbnail_image_url,
};
const member = await memberModel.loginSocial(request, data);
const msg = loginRules(member);
if(msg) {
return done(null, null, msg);
}
done(null, member);
} else {
done('로그인 실패', null);
Expand All @@ -100,13 +126,17 @@ module.exports = (app) => {
// console.log(profile);
// const member = await memberModel.loginNaver(request, profile);
const data = {
id : profile.id,
provider : profile.provider,
email : profile._json.email,
nickname : profile._json.nickname,
image : profile._json.profile_image,
id: profile.id,
provider: profile.provider,
email: profile._json.email,
nickname: profile._json.nickname,
image: profile._json.profile_image,
};
const member = await memberModel.loginSocial(request, data);
const msg = loginRules(member);
if(msg) {
return done(null, null, msg);
}
done(null, member);
} else {
done('로그인 실패', null);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed server/upload/memberPhoto/.cache/test4_w32_h32.jpg
Binary file not shown.
Binary file not shown.
Binary file removed server/upload/memberPhoto/5Pfsl2K7FO2z3VQn.jpg
Binary file not shown.
Binary file removed server/upload/memberPhoto/BvGoS5ZHp6uPnz4p.jpg
Binary file not shown.
Binary file removed server/upload/memberPhoto/JtOSKGvrKhVYhKKI.jpg
Binary file not shown.
Binary file removed server/upload/memberPhoto/OXKbnh5lwkqRSBTU.jpg
Binary file not shown.
Binary file removed server/upload/memberPhoto/Qyh1eodxwdeF4yJO.jpg
Binary file not shown.
Binary file removed server/upload/memberPhoto/RzSGu8zUFufOxW6p.jpg
Binary file not shown.
Binary file removed server/upload/memberPhoto/VgF5RqX6lbOtmhWM.jpg
Binary file not shown.
Binary file removed server/upload/memberPhoto/YS4qCEcybP0KW0h0.jpg
Binary file not shown.
Binary file removed server/upload/memberPhoto/dH237hIdYBvLTY42.jpg
Diff not rendered.
Binary file removed server/upload/memberPhoto/e79yLSLObGHPII0x.jpg
Diff not rendered.
Binary file removed server/upload/memberPhoto/fJZp57pZTq6rYOe4.jpg
Diff not rendered.
Binary file removed server/upload/memberPhoto/jV32i0IWfMEDERqK.jpg
Diff not rendered.
Binary file removed server/upload/memberPhoto/lID4ExTxw9uyYJmD.jpg
Diff not rendered.
Binary file removed server/upload/memberPhoto/t7BXXDrgReQlNogN.jpg
Diff not rendered.
Binary file removed server/upload/memberPhoto/test4.jpg
Diff not rendered.
Binary file removed server/upload/memberPhoto/uzpdyQ18GF3fBI4U.jpg
Diff not rendered.
3 changes: 3 additions & 0 deletions src/components/auth/UserUpdateForm.vue
Expand Up @@ -90,6 +90,9 @@

<v-btn type="submit" block color="primary" :loading="isLoading">
정보 수정
</v-btn>
<v-btn class="mt-4" block color="error" :loading="isLoading" @click="$emit('onLeave')">
회원 탈퇴
</v-btn>
</v-form>
</template>
Expand Down
26 changes: 25 additions & 1 deletion src/components/layout/SiteUser.vue
Expand Up @@ -36,6 +36,7 @@
:member="member"
:isLoading="isLoading"
@onSave="save"
@onLeave="leave"
/>
</v-card-text>
</v-card>
Expand Down Expand Up @@ -70,7 +71,7 @@ export default {
this.getDarkMode();
},
methods: {
...mapActions('user', ['checkPassword', 'updateMember']),
...mapActions('user', ['checkPassword', 'updateMember', 'signOut']),
setDarkMode(mode) {
this.$vuetify.theme.dark = mode;
localStorage.setItem("darkMode", mode ? "dark" : "light");
Expand Down Expand Up @@ -105,6 +106,29 @@ export default {
this.closeDialog();
}
this.isLoading = false;
},
async leave() {
const result = await this.$ezNotify.confirm(
'정말로 탈퇴 하시겠습니까?',
'회원탈퇴',
{icon : "mdi-alert"}
);
if(!result) return;
const form = {
mb_id : this.member.mb_id,
mb_leave_at : this.$moment().format('LT'),
};
this.isLoading = true;
const data = await this.updateMember(form);
this.isLoading = false;
if(data) {
this.closeDialog();
const mb_name = await this.signOut();
this.$toast.info(`${mb_name}님 탈퇴 하였습니다.`);
if(this.$route.name != 'Home') {
this.$router.push('/');
}
}
}
},
};
Expand Down
1 change: 1 addition & 0 deletions src/main.js
Expand Up @@ -6,6 +6,7 @@ import { sync } from "vuex-router-sync";

import vuetify from './plugins/vuetify'
import './plugins/axios'
import './plugins/moment';
import '@babel/polyfill'
import 'roboto-fontface/css/roboto/roboto-fontface.css'
import '@mdi/font/css/materialdesignicons.css'
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/moment.js
@@ -0,0 +1,3 @@
import Vue from 'vue';
import moment from '../../util/moment';
Vue.prototype.$moment = moment;

0 comments on commit e03cd4d

Please sign in to comment.