diff --git a/deploy.sh b/deploy.sh index 9fcb31c..9725f50 100755 --- a/deploy.sh +++ b/deploy.sh @@ -5,5 +5,6 @@ scp build/libs/luminic-space-v2.jar root@213.226.71.138:/root/luminic/space/back ssh root@213.226.71.138 " cd /root/luminic/space/back && - docker compose up -d --build + docker compose up -d --build && + docker restart back-app-1 " \ No newline at end of file diff --git a/src/main/kotlin/space/luminic/finance/api/AuthController.kt b/src/main/kotlin/space/luminic/finance/api/AuthController.kt index c4bac09..f48d687 100644 --- a/src/main/kotlin/space/luminic/finance/api/AuthController.kt +++ b/src/main/kotlin/space/luminic/finance/api/AuthController.kt @@ -81,10 +81,12 @@ class AuthController( } @PostMapping("/tg-login") - fun tgLogin(@RequestBody tgUser: UserDTO.TelegramAuthDTO): String { + fun tgLogin(@RequestBody tgUser: UserDTO.TelegramAuthDTO): Map { +// println(tgUser.hash) +// println(botToken) val ok = verifyTelegramAuth(tgUser.toTelegramMap(), botToken) if (!ok) throw IllegalArgumentException("Invalid Telegram login") - return authService.tgAuth(tgUser) + return mapOf("token" to authService.tgAuth(tgUser)) } diff --git a/src/main/kotlin/space/luminic/finance/configs/SecurityConfig.kt b/src/main/kotlin/space/luminic/finance/configs/SecurityConfig.kt index f60acf5..a51ab77 100644 --- a/src/main/kotlin/space/luminic/finance/configs/SecurityConfig.kt +++ b/src/main/kotlin/space/luminic/finance/configs/SecurityConfig.kt @@ -50,7 +50,7 @@ class SecurityConfig( @Bean fun corsConfigurationSource(): CorsConfigurationSource { val cors = CorsConfiguration().apply { - allowedOrigins = listOf("https://luminic.space", "http://localhost:5173") + allowedOrigins = listOf("https://app.luminic.space", "http://localhost:5173") allowedMethods = listOf("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH") allowedHeaders = listOf("*") allowCredentials = true diff --git a/src/main/kotlin/space/luminic/finance/repos/UserRepoImpl.kt b/src/main/kotlin/space/luminic/finance/repos/UserRepoImpl.kt index ba558b4..5511388 100644 --- a/src/main/kotlin/space/luminic/finance/repos/UserRepoImpl.kt +++ b/src/main/kotlin/space/luminic/finance/repos/UserRepoImpl.kt @@ -53,12 +53,12 @@ class UserRepoImpl( select * from finance.users u where tg_id = :tgId """.trimIndent() val params = mapOf("tgId" to tgId) - return jdbcTemplate.queryForObject(sql, params, userRowMapper()) + return jdbcTemplate.query(sql, params, userRowMapper()).firstOrNull() } override fun create(user: User): User { val sql = - "insert into finance.users(username, first_name, tg_id, tg_user_name, photo_url, password, is_active, reg_date) values (:username, :firstname, :tg_id, :tg_user_name, :photo_url :password, :isActive, :regDate) returning ID" + "insert into finance.users(username, first_name, tg_id, tg_user_name, photo_url, password, is_active, reg_date) values (:username, :firstname, :tg_id, :tg_user_name, :photo_url, :password, :isActive, :regDate) returning ID" val params = mapOf( "username" to user.username, "firstname" to user.firstName, diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 0f081e2..c7e91b5 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -18,7 +18,7 @@ logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE management.endpoints.web.exposure.include=* management.endpoint.health.show-details=always -telegram.bot.token=6972242509:AAGyXuL3T-BNE4XMoo_qvtaYxw_SuiS_dDs +telegram.bot.token=7999296388:AAGXPE5r0yt3ZFehBoUh8FGm5FBbs9pYIks nlp.address=http://127.0.0.1:8000 diff --git a/src/main/resources/db/migration/V23__.sql b/src/main/resources/db/migration/V23__.sql new file mode 100644 index 0000000..5fda7c1 --- /dev/null +++ b/src/main/resources/db/migration/V23__.sql @@ -0,0 +1,2 @@ +ALTER TABLE finance.users + ADD CONSTRAINT uq_users_username UNIQUE (username); \ No newline at end of file