PasswordChangeRecommendModal.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <div class="admin--modal-overlay">
  3. <div class="admin--modal password--recommend-modal">
  4. <div class="admin--modal-header">
  5. <h4>비밀번호 변경 권장</h4>
  6. </div>
  7. <div class="admin--modal-body">
  8. <div class="admin--warning-box">
  9. <svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  10. <path d="M12 2L2 20h20L12 2zm0 5.5l6.5 11h-13L12 7.5z" fill="#ff9800"/>
  11. <path d="M11 10h2v5h-2v-5zm0 6h2v2h-2v-2z" fill="#fff"/>
  12. </svg>
  13. <h3>비밀번호 변경이 필요합니다</h3>
  14. <p>마지막 비밀번호 변경 후 6개월이 경과하였습니다.</p>
  15. <p>보안을 위해 비밀번호를 변경해주세요.</p>
  16. </div>
  17. <form @submit.prevent="changePassword" v-if="showPasswordForm">
  18. <div class="admin--form-group">
  19. <label class="admin--form-label">현재 비밀번호 *</label>
  20. <input
  21. v-model="formData.current_password"
  22. type="password"
  23. class="admin--form-input"
  24. required
  25. placeholder="현재 비밀번호 입력"
  26. />
  27. </div>
  28. <div class="admin--form-group">
  29. <label class="admin--form-label">새 비밀번호 *</label>
  30. <input
  31. v-model="formData.new_password"
  32. type="password"
  33. class="admin--form-input"
  34. required
  35. placeholder="최소 8자 이상"
  36. minlength="8"
  37. />
  38. </div>
  39. <div class="admin--form-group">
  40. <label class="admin--form-label">새 비밀번호 확인 *</label>
  41. <input
  42. v-model="formData.new_password_confirm"
  43. type="password"
  44. class="admin--form-input"
  45. required
  46. placeholder="새 비밀번호 재입력"
  47. minlength="8"
  48. />
  49. </div>
  50. <div v-if="errorMessage" class="admin--error-message">
  51. {{ errorMessage }}
  52. </div>
  53. </form>
  54. </div>
  55. <div class="admin--modal-footer">
  56. <button
  57. type="button"
  58. @click="skipAndContinue"
  59. class="admin--btn-small admin--btn-small-secondary"
  60. >
  61. 나중에 변경
  62. </button>
  63. <button
  64. v-if="!showPasswordForm"
  65. type="button"
  66. @click="showPasswordForm = true"
  67. class="admin--btn-small admin--btn-small-primary"
  68. >
  69. 지금 변경
  70. </button>
  71. <button
  72. v-else
  73. type="button"
  74. @click="changePassword"
  75. class="admin--btn-small admin--btn-small-primary"
  76. :disabled="saving"
  77. >
  78. {{ saving ? '변경 중...' : '변경' }}
  79. </button>
  80. </div>
  81. </div>
  82. </div>
  83. </template>
  84. <script setup>
  85. import { ref } from 'vue'
  86. const props = defineProps({
  87. adminId: {
  88. type: Number,
  89. required: true
  90. }
  91. })
  92. const emit = defineEmits(['close', 'changed'])
  93. const { post } = useApi()
  94. const showPasswordForm = ref(false)
  95. const saving = ref(false)
  96. const errorMessage = ref('')
  97. const formData = ref({
  98. current_password: '',
  99. new_password: '',
  100. new_password_confirm: ''
  101. })
  102. const skipAndContinue = () => {
  103. emit('close')
  104. }
  105. const changePassword = async () => {
  106. errorMessage.value = ''
  107. // 비밀번호 확인
  108. if (formData.value.new_password !== formData.value.new_password_confirm) {
  109. errorMessage.value = '새 비밀번호가 일치하지 않습니다.'
  110. return
  111. }
  112. if (formData.value.new_password.length < 8) {
  113. errorMessage.value = '비밀번호는 최소 8자 이상이어야 합니다.'
  114. return
  115. }
  116. if (!formData.value.current_password) {
  117. errorMessage.value = '현재 비밀번호를 입력해주세요.'
  118. return
  119. }
  120. saving.value = true
  121. try {
  122. const requestData = {
  123. current_password: formData.value.current_password,
  124. new_password: formData.value.new_password
  125. }
  126. const { data, error } = await post(`/admin/${props.adminId}/password`, requestData)
  127. if (error) {
  128. console.error('[PasswordChangeRecommendModal] 변경 실패:', error)
  129. errorMessage.value = error.response?.data?.message || '비밀번호 변경에 실패했습니다.'
  130. return
  131. }
  132. if (data?.success) {
  133. emit('changed', '비밀번호가 변경되었습니다.')
  134. }
  135. } finally {
  136. saving.value = false
  137. }
  138. }
  139. </script>
  140. <style>
  141. .admin--modal-overlay {
  142. position: fixed;
  143. top: 0;
  144. left: 0;
  145. right: 0;
  146. bottom: 0;
  147. background: rgba(0, 0, 0, 0.5);
  148. z-index: 9999;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. }
  153. .admin--modal {
  154. background: #ffffff;
  155. padding: 0;
  156. border-radius: 8px;
  157. min-width: 500px;
  158. max-width: 600px;
  159. width: 90%;
  160. box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  161. max-height: 90vh;
  162. display: flex;
  163. flex-direction: column;
  164. }
  165. .password--recommend-modal {
  166. border: 2px solid #ff9800;
  167. }
  168. .admin--modal-header {
  169. padding: 20px;
  170. border-bottom: 1px solid #e0e0e0;
  171. display: flex;
  172. justify-content: space-between;
  173. align-items: center;
  174. flex-shrink: 0;
  175. background: #fafafa;
  176. }
  177. .admin--modal-header h4 {
  178. margin: 0;
  179. font-size: 18px;
  180. font-weight: 600;
  181. color: #1a1a1a;
  182. }
  183. .admin--modal-body {
  184. padding: 24px;
  185. overflow-y: auto;
  186. flex: 1;
  187. min-height: 0;
  188. }
  189. .admin--warning-box {
  190. text-align: center;
  191. padding: 20px;
  192. margin-bottom: 24px;
  193. }
  194. .admin--warning-box svg {
  195. margin: 0 auto 16px;
  196. display: block;
  197. }
  198. .admin--warning-box h3 {
  199. margin: 0 0 12px 0;
  200. font-size: 20px;
  201. font-weight: 600;
  202. color: #ff9800;
  203. }
  204. .admin--warning-box p {
  205. margin: 6px 0;
  206. color: #333333;
  207. font-size: 14px;
  208. line-height: 1.6;
  209. }
  210. .admin--form-group {
  211. display: flex;
  212. flex-direction: column;
  213. margin-bottom: 20px;
  214. }
  215. .admin--form-group:last-child {
  216. margin-bottom: 0;
  217. }
  218. .admin--form-label {
  219. display: block;
  220. margin-bottom: 8px;
  221. font-size: 14px;
  222. font-weight: 500;
  223. color: #333333;
  224. }
  225. .admin--form-input {
  226. width: 100%;
  227. padding: 10px 14px;
  228. border: 1px solid #e0e0e0;
  229. border-radius: 4px;
  230. background: #ffffff;
  231. color: #333333;
  232. font-size: 14px;
  233. transition: border-color 0.2s;
  234. }
  235. .admin--form-input:focus {
  236. outline: none;
  237. border-color: var(--admin-accent-primary, #217346);
  238. }
  239. .admin--form-input::placeholder {
  240. color: #999;
  241. }
  242. .admin--error-message {
  243. margin-top: 12px;
  244. padding: 12px;
  245. background: rgba(244, 67, 54, 0.1);
  246. border: 1px solid rgba(244, 67, 54, 0.3);
  247. border-radius: 4px;
  248. color: #f44336;
  249. font-size: 13px;
  250. }
  251. .admin--modal-footer {
  252. padding: 20px 24px;
  253. border-top: 1px solid #e0e0e0;
  254. display: flex;
  255. gap: 10px;
  256. justify-content: flex-end;
  257. flex-shrink: 0;
  258. }
  259. </style>