build
This commit is contained in:
@@ -81,10 +81,12 @@ class AuthController(
|
||||
}
|
||||
|
||||
@PostMapping("/tg-login")
|
||||
fun tgLogin(@RequestBody tgUser: UserDTO.TelegramAuthDTO): String {
|
||||
fun tgLogin(@RequestBody tgUser: UserDTO.TelegramAuthDTO): Map<String, String> {
|
||||
// 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))
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user