Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji-InPark committed May 14, 2024
2 parents 4767d60 + a18ad88 commit 26dd2f7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 102 deletions.
12 changes: 0 additions & 12 deletions src/main/kotlin/com/kioschool/kioschoolapi/bank/entity/BankCode.kt

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.kioschool.kioschoolapi.user.service

import com.kioschool.kioschoolapi.bank.service.BankService
import com.kioschool.kioschoolapi.common.enums.UserRole
import com.kioschool.kioschoolapi.discord.DiscordService
import com.kioschool.kioschoolapi.email.service.EmailService
import com.kioschool.kioschoolapi.security.JwtProvider
import com.kioschool.kioschoolapi.user.entity.User
import com.kioschool.kioschoolapi.user.exception.*
import com.kioschool.kioschoolapi.user.exception.LoginFailedException
import com.kioschool.kioschoolapi.user.exception.NoPermissionException
import com.kioschool.kioschoolapi.user.exception.RegisterException
import com.kioschool.kioschoolapi.user.exception.UserNotFoundException
import com.kioschool.kioschoolapi.user.repository.UserRepository
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.stereotype.Service
Expand All @@ -17,7 +19,6 @@ class UserService(
private val jwtProvider: JwtProvider,
private val passwordEncoder: PasswordEncoder,
private val emailService: EmailService,
private val bankService: BankService,
private val discordService: DiscordService
) {
fun login(loginId: String, loginPassword: String): String {
Expand Down Expand Up @@ -78,27 +79,9 @@ class UserService(
val user = getUser(username)
user.accountUrl = accountUrl.replace(Regex("amount=\\d+&"), "")

checkBankHolderNameMatched(accountUrl, user.name)

return userRepository.save(user)
}

private fun checkBankHolderNameMatched(accountUrl: String, username: String) {
val bankName = extractBankName(accountUrl)
val accountNumber = extractAccountNumber(accountUrl)
val bankHolderName = bankService.getBankAccountHolderName(bankName, accountNumber)

if (bankHolderName != username) throw BankHolderNotMatchedException()
}

private fun extractBankName(accountUrl: String): String {
return accountUrl.substringAfter("bank=").substringBefore("&")
}

private fun extractAccountNumber(accountUrl: String): String {
return accountUrl.substringAfter("accountNo=").substringBefore("&")
}

fun sendResetPasswordEmail(loginId: String, email: String) {
val user = userRepository.findByLoginId(loginId) ?: throw UserNotFoundException()
if (user.email != email) throw UserNotFoundException()
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/db/changelog/2024/05/14-01-changelog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
objectQuotingStrategy="QUOTE_ONLY_RESERVED_WORDS"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.24.xsd">
<changeSet author="ji-inpark (generated)" id="1715663698925-3">
<dropTable cascadeConstraints="true" schemaName="public" tableName="bank_code"/>
</changeSet>

</databaseChangeLog>

0 comments on commit 26dd2f7

Please sign in to comment.