...
This commit is contained in:
parent
a02349f7a1
commit
576932da3d
@ -52,7 +52,11 @@ dependencies {
|
|||||||
implementation ("com.drewnoakes:metadata-extractor:2.19.0")
|
implementation ("com.drewnoakes:metadata-extractor:2.19.0")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||||
compileOnly("org.projectlombok:lombok")
|
compileOnly("org.projectlombok:lombok")
|
||||||
// runtimeOnly("org.mariadb.jdbc:mariadb-java-client")
|
|
||||||
|
implementation("io.jsonwebtoken:jjwt-api:0.11.5")
|
||||||
|
implementation("io.jsonwebtoken:jjwt-impl:0.11.5")
|
||||||
|
implementation("io.jsonwebtoken:jjwt-jackson:0.11.5")
|
||||||
|
|
||||||
annotationProcessor("org.projectlombok:lombok")
|
annotationProcessor("org.projectlombok:lombok")
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||||
testImplementation("io.projectreactor:reactor-test")
|
testImplementation("io.projectreactor:reactor-test")
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package kr.lunaticbum.back.lun.configs
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
|
||||||
|
|
||||||
|
|
||||||
@ -17,6 +18,10 @@ class AppConfig : WebMvcConfigurer {
|
|||||||
registry.addResourceHandler(resourceHandler).addResourceLocations(resourceLocation)
|
registry.addResourceHandler(resourceHandler).addResourceLocations(resourceLocation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun addInterceptors(registry: InterceptorRegistry) {
|
||||||
|
registry.addInterceptor(BumsInterceptor())
|
||||||
|
super.addInterceptors(registry)
|
||||||
|
}
|
||||||
// @Bean
|
// @Bean
|
||||||
// fun getProperty() : Map<String,String>{
|
// fun getProperty() : Map<String,String>{
|
||||||
// println("telegramBotKey >>>> $telegramBotKey")
|
// println("telegramBotKey >>>> $telegramBotKey")
|
||||||
|
|||||||
@ -0,0 +1,43 @@
|
|||||||
|
package kr.lunaticbum.back.lun.configs
|
||||||
|
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import jakarta.servlet.http.Cookie
|
||||||
|
import jakarta.servlet.http.HttpServletRequest
|
||||||
|
import jakarta.servlet.http.HttpServletResponse
|
||||||
|
import org.springframework.lang.Nullable
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor
|
||||||
|
import org.springframework.web.servlet.ModelAndView
|
||||||
|
|
||||||
|
|
||||||
|
class BumsInterceptor : HandlerInterceptor{
|
||||||
|
@Throws(Exception::class)
|
||||||
|
override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean {
|
||||||
|
println("===============================================")
|
||||||
|
println("==================== BEGIN ====================")
|
||||||
|
println("Request URL ===> " + request.requestURL)
|
||||||
|
return super.preHandle(request, response, handler)
|
||||||
|
}
|
||||||
|
val WRITE_PERMISSION_KEY = "PERMISSION"
|
||||||
|
@Throws(Exception::class)
|
||||||
|
override fun postHandle(
|
||||||
|
request: HttpServletRequest,
|
||||||
|
response: HttpServletResponse,
|
||||||
|
handler: Any,
|
||||||
|
@Nullable modelAndView: ModelAndView?
|
||||||
|
) {
|
||||||
|
if (request.requestURI.contains("logout") == false && !request.cookies.isNullOrEmpty() && request.cookies.filter { it.name.equals("S33-DATA") && it.value.length > 0 }.size > 0) {
|
||||||
|
response.addCookie(Cookie("S33-DATA",request.cookies.filter { it.name.equals("S33-DATA") && it.value.length > 0 }.get(0).value))
|
||||||
|
modelAndView?.modelMap?.put(WRITE_PERMISSION_KEY,"OK")
|
||||||
|
println("Response modelMap ===> ${Gson().toJson(modelAndView?.modelMap)}")
|
||||||
|
} else if (request.requestURI.contains("logout")) {
|
||||||
|
response.addCookie(Cookie("S33-DATA",null))
|
||||||
|
modelAndView?.modelMap?.put(WRITE_PERMISSION_KEY,"NO")
|
||||||
|
}
|
||||||
|
|
||||||
|
println("==================== END ======================")
|
||||||
|
println("===============================================")
|
||||||
|
|
||||||
|
super.postHandle(request, response, handler, modelAndView)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -41,6 +41,7 @@ class SecurityConfig {
|
|||||||
frameOptionsConfig.disable()
|
frameOptionsConfig.disable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
http.authorizeHttpRequests {
|
http.authorizeHttpRequests {
|
||||||
logService.log(it.toString())
|
logService.log(it.toString())
|
||||||
it.requestMatchers(HttpMethod.POST,"/user/**").permitAll()
|
it.requestMatchers(HttpMethod.POST,"/user/**").permitAll()
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import org.springframework.http.ResponseEntity
|
|||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
import org.springframework.web.multipart.MultipartFile
|
import org.springframework.web.multipart.MultipartFile
|
||||||
import org.springframework.web.reactive.function.client.WebClient
|
import org.springframework.web.reactive.function.client.WebClient
|
||||||
import org.springframework.web.servlet.ModelAndView
|
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.net.URLDecoder
|
import java.net.URLDecoder
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
@ -47,8 +46,8 @@ class BlogController() {
|
|||||||
lateinit var logService: LogService
|
lateinit var logService: LogService
|
||||||
val WRITE_PERMISSION_KEY = "PERMISSION"
|
val WRITE_PERMISSION_KEY = "PERMISSION"
|
||||||
@GetMapping("write/{token}","write")
|
@GetMapping("write/{token}","write")
|
||||||
fun writ(@PathVariable token : String? ) : ModelAndView{
|
fun writ(@PathVariable token : String? ) : ResultMV{
|
||||||
val vm = ModelAndView("content/blog/write")
|
val vm = ResultMV("content/blog/write")
|
||||||
if (token.equals(TEMPTOKEN)) {
|
if (token.equals(TEMPTOKEN)) {
|
||||||
vm.modelMap.put(WRITE_PERMISSION_KEY,"OK")
|
vm.modelMap.put(WRITE_PERMISSION_KEY,"OK")
|
||||||
vm.modelMap.put(EncTypeKey, EncType11)
|
vm.modelMap.put(EncTypeKey, EncType11)
|
||||||
@ -126,8 +125,8 @@ class BlogController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("viewer/{postId}")
|
@GetMapping("viewer/{postId}")
|
||||||
fun viewer(@PathVariable postId : String) : ModelAndView{
|
fun viewer(@PathVariable postId : String) : ResultMV{
|
||||||
val vm = ModelAndView("content/blog/viewer")
|
val vm = ResultMV("content/blog/viewer")
|
||||||
postManageg.getPost(postId).block().apply {
|
postManageg.getPost(postId).block().apply {
|
||||||
this?.title = URLDecoder.decode(this?.title)
|
this?.title = URLDecoder.decode(this?.title)
|
||||||
this?.content = URLDecoder.decode(this?.content)
|
this?.content = URLDecoder.decode(this?.content)
|
||||||
@ -137,9 +136,9 @@ class BlogController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("modify")
|
@GetMapping("modify")
|
||||||
fun modify(@RequestParam("token") token : String?) : ModelAndView{
|
fun modify(@RequestParam("token") token : String?) : ResultMV{
|
||||||
logService.log("incoming modify")
|
logService.log("incoming modify")
|
||||||
val vm = ModelAndView("content/blog/modify")
|
val vm = ResultMV("content/blog/modify")
|
||||||
if (TEMPTOKEN.equals(token)) {
|
if (TEMPTOKEN.equals(token)) {
|
||||||
postManageg.find20()?.apply {
|
postManageg.find20()?.apply {
|
||||||
forEach {
|
forEach {
|
||||||
@ -160,8 +159,8 @@ class BlogController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("editor/{postId}")
|
@GetMapping("editor/{postId}")
|
||||||
fun editor(@PathVariable postId : String, @RequestParam("token") token : String?) : ModelAndView{
|
fun editor(@PathVariable postId : String, @RequestParam("token") token : String?) : ResultMV{
|
||||||
val vm = ModelAndView("content/blog/editor")
|
val vm = ResultMV("content/blog/editor")
|
||||||
postManageg.getPost(postId).block().apply {
|
postManageg.getPost(postId).block().apply {
|
||||||
this?.title = URLDecoder.decode(this?.title)
|
this?.title = URLDecoder.decode(this?.title)
|
||||||
this?.content = URLDecoder.decode(this?.content)
|
this?.content = URLDecoder.decode(this?.content)
|
||||||
@ -177,8 +176,8 @@ class BlogController() {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("recent")
|
@GetMapping("recent")
|
||||||
fun recent() : ModelAndView{
|
fun recent() : ResultMV{
|
||||||
val vm = ModelAndView("content/blog/viewer")
|
val vm = ResultMV("content/blog/viewer")
|
||||||
locationLogService.find20().forEach {
|
locationLogService.find20().forEach {
|
||||||
logService.log(Gson().toJson(it))
|
logService.log(Gson().toJson(it))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,17 +6,16 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kr.lunaticbum.back.lun.configs.GlobalEnvironment
|
import kr.lunaticbum.back.lun.configs.GlobalEnvironment
|
||||||
import kr.lunaticbum.back.lun.model.LocationLog
|
import kr.lunaticbum.back.lun.model.*
|
||||||
import kr.lunaticbum.back.lun.model.LocationLogService
|
|
||||||
import kr.lunaticbum.back.lun.model.ResponceResult
|
|
||||||
import kr.lunaticbum.back.lun.utils.LogService
|
import kr.lunaticbum.back.lun.utils.LogService
|
||||||
|
import kr.lunaticbum.back.lun.utils.plainText
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.http.MediaType
|
import org.springframework.http.MediaType
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
import org.springframework.web.reactive.function.client.WebClient
|
import org.springframework.web.reactive.function.client.WebClient
|
||||||
import org.springframework.web.servlet.ModelAndView
|
import org.springframework.web.servlet.ModelAndView
|
||||||
import java.util.*
|
import java.util.Base64
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -32,15 +31,15 @@ class BumsPrivate {
|
|||||||
lateinit var locationService: LocationLogService
|
lateinit var locationService: LocationLogService
|
||||||
|
|
||||||
@GetMapping("where")
|
@GetMapping("where")
|
||||||
fun where() : ModelAndView {
|
fun where() : ResultMV {
|
||||||
val m = ModelAndView("content/private/where")
|
val m = ResultMV("content/private/where")
|
||||||
locationService.find20().apply {
|
locationService.find20().apply {
|
||||||
m.modelMap.put("locations",this.reversed())
|
m.modelMap.put("locations",this.reversed())
|
||||||
forEach {
|
// forEach {
|
||||||
logService.log(it.timeString.plus(it.mAddressLines.joinToString(",")))
|
// logService.log(it.timeString.plus(it.mAddressLines.joinToString(",")))
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
m.modelMap.put("title","돼지 여기있다요~!!")
|
m.setTitle("돼지 여기있다요~!!")
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,11 +48,9 @@ class BumsPrivate {
|
|||||||
fun login(httpServletRequest: HttpServletRequest, @RequestBody jsonString: String) : ResponseEntity<ResponceResult> {
|
fun login(httpServletRequest: HttpServletRequest, @RequestBody jsonString: String) : ResponseEntity<ResponceResult> {
|
||||||
logService.log("${httpServletRequest.requestURI}")
|
logService.log("${httpServletRequest.requestURI}")
|
||||||
logService.log(jsonString)
|
logService.log(jsonString)
|
||||||
var lResultCode = 0
|
|
||||||
var lResultMsg = "Suscces"
|
|
||||||
var location : LocationLog? = null
|
var location : LocationLog? = null
|
||||||
val decodedBytes: ByteArray = Base64.getMimeDecoder().decode(jsonString)
|
jsonString.plainText().let {
|
||||||
String(decodedBytes).let {
|
|
||||||
Gson().fromJson<LocationLog>(it, LocationLog::class.java)?.let { model ->
|
Gson().fromJson<LocationLog>(it, LocationLog::class.java)?.let { model ->
|
||||||
location = model
|
location = model
|
||||||
logService.log(model.toString())
|
logService.log(model.toString())
|
||||||
@ -61,8 +58,7 @@ class BumsPrivate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val responce = ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(ResponceResult().apply {
|
val responce = ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(ResponceResult().apply {
|
||||||
this.resultCode = lResultCode
|
|
||||||
this.resultMsg = lResultMsg
|
|
||||||
})
|
})
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
location?.let {
|
location?.let {
|
||||||
|
|||||||
@ -3,13 +3,13 @@ package kr.lunaticbum.back.lun.controllers
|
|||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import jakarta.servlet.http.HttpServletResponse
|
import jakarta.servlet.http.HttpServletResponse
|
||||||
import kr.lunaticbum.back.lun.model.PostManageg
|
import kr.lunaticbum.back.lun.model.PostManageg
|
||||||
|
import kr.lunaticbum.back.lun.model.ResultMV
|
||||||
import kr.lunaticbum.back.lun.utils.LogService
|
import kr.lunaticbum.back.lun.utils.LogService
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.data.domain.Pageable
|
import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.RequestMapping
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
import org.springframework.web.bind.annotation.RestController
|
import org.springframework.web.bind.annotation.RestController
|
||||||
import org.springframework.web.servlet.ModelAndView
|
|
||||||
import java.net.URLDecoder
|
import java.net.URLDecoder
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -23,8 +23,8 @@ class Home {
|
|||||||
private lateinit var postManageg: PostManageg
|
private lateinit var postManageg: PostManageg
|
||||||
|
|
||||||
@GetMapping("/","/home")
|
@GetMapping("/","/home")
|
||||||
fun home() : ModelAndView {
|
fun home() : ResultMV {
|
||||||
val vm = ModelAndView("content/home")
|
val vm = ResultMV("content/home")
|
||||||
vm.modelMap.put("Posts", postManageg.find20(Pageable.ofSize(20)).apply {
|
vm.modelMap.put("Posts", postManageg.find20(Pageable.ofSize(20)).apply {
|
||||||
this.forEach {
|
this.forEach {
|
||||||
it.title = URLDecoder.decode(it.title)
|
it.title = URLDecoder.decode(it.title)
|
||||||
@ -41,8 +41,8 @@ class Home {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/licenses")
|
@GetMapping("/licenses")
|
||||||
fun licenses() : ModelAndView {
|
fun licenses() : ResultMV {
|
||||||
val vm = ModelAndView("content/licenses")
|
val vm = ResultMV("content/licenses")
|
||||||
return vm
|
return vm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,18 +6,16 @@ import kr.lunaticbum.back.lun.configs.GlobalEnvironment
|
|||||||
import kr.lunaticbum.back.lun.configs.GlobalEnvironment.Companion.ApiKeyWordKey
|
import kr.lunaticbum.back.lun.configs.GlobalEnvironment.Companion.ApiKeyWordKey
|
||||||
import kr.lunaticbum.back.lun.configs.GlobalEnvironment.Companion.EncType11
|
import kr.lunaticbum.back.lun.configs.GlobalEnvironment.Companion.EncType11
|
||||||
import kr.lunaticbum.back.lun.configs.GlobalEnvironment.Companion.EncTypeKey
|
import kr.lunaticbum.back.lun.configs.GlobalEnvironment.Companion.EncTypeKey
|
||||||
import kr.lunaticbum.back.lun.model.RequestModel
|
import kr.lunaticbum.back.lun.model.*
|
||||||
import kr.lunaticbum.back.lun.model.ResponceResult
|
|
||||||
import kr.lunaticbum.back.lun.model.User
|
|
||||||
import kr.lunaticbum.back.lun.model.UserManager
|
|
||||||
import kr.lunaticbum.back.lun.utils.LogService
|
import kr.lunaticbum.back.lun.utils.LogService
|
||||||
|
import kr.lunaticbum.back.lun.utils.extractModelData
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.http.MediaType
|
import org.springframework.http.MediaType
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.security.core.userdetails.UserDetails
|
import org.springframework.security.core.userdetails.UserDetails
|
||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
import org.springframework.web.reactive.function.client.WebClient
|
import org.springframework.web.reactive.function.client.WebClient
|
||||||
import org.springframework.web.servlet.ModelAndView
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -37,9 +35,9 @@ class UserController {
|
|||||||
lateinit var userManager: UserManager
|
lateinit var userManager: UserManager
|
||||||
|
|
||||||
@GetMapping("join")
|
@GetMapping("join")
|
||||||
fun hello(httpServletRequest: HttpServletRequest): ModelAndView {
|
fun hello(httpServletRequest: HttpServletRequest): ResultMV {
|
||||||
logService.log("onJoin")
|
logService.log("onJoin")
|
||||||
val vm = ModelAndView("content/user/join")
|
val vm = ResultMV("content/user/join")
|
||||||
// when(System.currentTimeMillis() % 5L) {
|
// when(System.currentTimeMillis() % 5L) {
|
||||||
// 0L -> vm.modelMap.put(EncTypeKey,"T4")
|
// 0L -> vm.modelMap.put(EncTypeKey,"T4")
|
||||||
// 1L -> vm.modelMap.put(EncTypeKey,"T3")
|
// 1L -> vm.modelMap.put(EncTypeKey,"T3")
|
||||||
@ -56,9 +54,9 @@ class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("login")
|
@GetMapping("login")
|
||||||
fun userLogin(httpServletRequest: HttpServletRequest): ModelAndView {
|
fun userLogin(httpServletRequest: HttpServletRequest): ResultMV {
|
||||||
logService.log("onJoin")
|
logService.log("onJoin")
|
||||||
val vm = ModelAndView("content/user/login")
|
val vm = ResultMV("content/user/login")
|
||||||
// when(System.currentTimeMillis() % 5L) {
|
// when(System.currentTimeMillis() % 5L) {
|
||||||
// 0L -> vm.modelMap.put(EncTypeKey,"T4")
|
// 0L -> vm.modelMap.put(EncTypeKey,"T4")
|
||||||
// 1L -> vm.modelMap.put(EncTypeKey,"T3")
|
// 1L -> vm.modelMap.put(EncTypeKey,"T3")
|
||||||
@ -79,45 +77,48 @@ class UserController {
|
|||||||
var lResultCode = 0
|
var lResultCode = 0
|
||||||
var lResultMsg = "Suscces"
|
var lResultMsg = "Suscces"
|
||||||
var u : UserDetails? = null
|
var u : UserDetails? = null
|
||||||
val decodedBytes: ByteArray = Base64.getDecoder().decode(jsonString)
|
jsonString.extractModelData { exception, originDataString ->
|
||||||
String(decodedBytes).let {
|
if (exception == null) {
|
||||||
Gson().fromJson<RequestModel>(it,RequestModel::class.java)?.let { model ->
|
logService.log(originDataString)
|
||||||
logService.log(Gson().toJson(model))
|
val target = Gson().fromJson(originDataString, User::class.java) ?: User()
|
||||||
model.data?.let { jsonString ->
|
var user = userManager.findById(target.user_id!!)?.block()
|
||||||
try {
|
if (user == null && ((target.user_id?.length ?: 0) > 3 == true)) {
|
||||||
val originDataString = model.extractData()
|
user = userManager.findByEmail(target.user_id!!)?.block()
|
||||||
logService.log(originDataString)
|
|
||||||
val target = Gson().fromJson(originDataString, User::class.java) ?: User()
|
|
||||||
var user = userManager.findById(target.user_id!!)?.block()
|
|
||||||
if (user == null && ((target.user_id?.length ?: 0) > 3 == true)) {
|
|
||||||
user = userManager.findByEmail(target.user_id!!)?.block()
|
|
||||||
}
|
|
||||||
if (user != null) {
|
|
||||||
if(userManager.isCorrectUser(user,target.user_pw!!)){
|
|
||||||
|
|
||||||
} else {
|
|
||||||
lResultMsg = "is wrong infomation id or passord"
|
|
||||||
lResultCode = 7100
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lResultMsg = "not founding user[can't find same id,email.. ]"
|
|
||||||
lResultCode = 7100
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
lResultMsg = "unknown exception"
|
|
||||||
lResultCode = 7999
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (user != null) {
|
||||||
|
if(userManager.isCorrectUser(user,target.user_pw!!)){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
lResultMsg = "is wrong infomation id or passord"
|
||||||
|
lResultCode = 7100
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lResultMsg = "not founding user[can't find same id,email.. ]"
|
||||||
|
lResultCode = 7100
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
exception.printStackTrace()
|
||||||
|
lResultMsg = exception.message ?: "unknown exception"
|
||||||
|
lResultCode = 7999
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val responce = ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(ResponceResult().apply {
|
val responce = ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).headers {
|
||||||
|
it.put("S33-DATA", listOf(UUID.randomUUID().toString()))
|
||||||
|
}.body(ResponceResult().apply {
|
||||||
this.resultCode = lResultCode
|
this.resultCode = lResultCode
|
||||||
this.resultMsg = lResultMsg
|
this.resultMsg = lResultMsg
|
||||||
})
|
})
|
||||||
return responce
|
return responce
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("logout.ajax")
|
||||||
|
fun logout(httpServletRequest: HttpServletRequest) : ResponseEntity<ResponceResult> {
|
||||||
|
val responce = ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(ResponceResult().apply {
|
||||||
|
|
||||||
|
})
|
||||||
|
return responce
|
||||||
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostMapping("joinUser.ajax")
|
@PostMapping("joinUser.ajax")
|
||||||
@ -127,33 +128,25 @@ class UserController {
|
|||||||
var lResultCode = 0
|
var lResultCode = 0
|
||||||
var lResultMsg = "Suscces"
|
var lResultMsg = "Suscces"
|
||||||
var u : User? = null
|
var u : User? = null
|
||||||
val decodedBytes: ByteArray = Base64.getDecoder().decode(jsonString)
|
jsonString.extractModelData { exception, s ->
|
||||||
String(decodedBytes).let {
|
if (exception == null) {
|
||||||
Gson().fromJson<RequestModel>(it,RequestModel::class.java)?.let { model ->
|
val user = Gson().fromJson(s, User::class.java) ?: User()
|
||||||
logService.log(Gson().toJson(model))
|
if (user.checkValid() == false) {
|
||||||
model.data?.let { jsonString ->
|
lResultCode = 7009
|
||||||
try {
|
lResultMsg = "user insert Fail Reason : Not Correct Data"
|
||||||
val originDataString = model.extractData()
|
}else if (userManager.findById(user!!.user_id!!)?.block() != null) {
|
||||||
logService.log(originDataString)
|
lResultCode = 7001
|
||||||
val user = Gson().fromJson(originDataString, User::class.java) ?: User()
|
lResultMsg = "user insert Fail Reason : already has Same Id"
|
||||||
if (user.checkValid() == false) {
|
}else if (userManager.findByEmail(user!!.user_email!!)?.block() != null ) {
|
||||||
lResultCode = 7009
|
lResultCode = 7002
|
||||||
lResultMsg = "user insert Fail Reason : Not Correct Data"
|
lResultMsg = "user insert Fail Reason : already has Same Email"
|
||||||
}else if (userManager.findById(user!!.user_id!!)?.block() != null) {
|
} else {
|
||||||
lResultCode = 7001
|
u = userManager.save(user).block()
|
||||||
lResultMsg = "user insert Fail Reason : already has Same Id"
|
|
||||||
}else if (userManager.findByEmail(user!!.user_email!!)?.block() != null ) {
|
|
||||||
lResultCode = 7002
|
|
||||||
lResultMsg = "user insert Fail Reason : already has Same Email"
|
|
||||||
} else {
|
|
||||||
u = userManager.save(user).block()
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
lResultMsg = "unknown exception"
|
|
||||||
lResultCode = 7999
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
exception.printStackTrace()
|
||||||
|
lResultMsg = exception.message ?: "unknown exception"
|
||||||
|
lResultCode = 7999
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val responce = ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(ResponceResult().apply {
|
val responce = ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(ResponceResult().apply {
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
package kr.lunaticbum.back.lun.model
|
||||||
|
|
||||||
|
open class BaseResult {
|
||||||
|
var resultCode = 0
|
||||||
|
var resultMsg = "Suscces"
|
||||||
|
var isOk = true
|
||||||
|
}
|
||||||
@ -4,9 +4,8 @@ import lombok.Getter
|
|||||||
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
open class ResponceResult {
|
open class ResponceResult : BaseResult() {
|
||||||
var resultCode: Int = 0
|
|
||||||
var resultMsg: String? = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
26
src/main/kotlin/kr/lunaticbum/back/lun/model/ResultMV.kt
Normal file
26
src/main/kotlin/kr/lunaticbum/back/lun/model/ResultMV.kt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package kr.lunaticbum.back.lun.model
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatusCode
|
||||||
|
import org.springframework.web.servlet.ModelAndView
|
||||||
|
import org.springframework.web.servlet.View
|
||||||
|
|
||||||
|
class ResultMV : ModelAndView {
|
||||||
|
|
||||||
|
constructor() : super()
|
||||||
|
constructor(viewName: String) : super(viewName)
|
||||||
|
constructor(view: View) : super(view)
|
||||||
|
constructor(viewName: String, model: MutableMap<String, *>?) : super(viewName, model)
|
||||||
|
constructor(view: View, model: MutableMap<String, *>?) : super(view, model)
|
||||||
|
constructor(viewName: String, status: HttpStatusCode) : super(viewName, status)
|
||||||
|
constructor(viewName: String?, model: MutableMap<String, *>?, status: HttpStatusCode?) : super(viewName, model, status)
|
||||||
|
constructor(viewName: String, modelName: String, modelObject: Any) : super(viewName, modelName, modelObject)
|
||||||
|
constructor(view: View, modelName: String, modelObject: Any) : super(view, modelName, modelObject)
|
||||||
|
|
||||||
|
init {
|
||||||
|
modelMap.put("title", "LUNATICBUM")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTitle(title : String){
|
||||||
|
modelMap.put("title", title)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,9 @@
|
|||||||
//package kr.lunaticbum.back.lun.utils
|
package kr.lunaticbum.back.lun.utils
|
||||||
|
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import kr.lunaticbum.back.lun.model.RequestModel
|
||||||
|
import java.util.Base64
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//import javax.crypto.Cipher
|
//import javax.crypto.Cipher
|
||||||
@ -49,4 +54,31 @@
|
|||||||
// //Decode Base64
|
// //Decode Base64
|
||||||
//// byte[] decodeByte = Base64.decodeBase64(encodeText);
|
//// byte[] decodeByte = Base64.decodeBase64(encodeText);
|
||||||
// return String(c.doFinal(decodeByte), charset("UTF-8"))
|
// return String(c.doFinal(decodeByte), charset("UTF-8"))
|
||||||
//}
|
//}
|
||||||
|
fun String.plainText() = String(Base64.getMimeDecoder().decode(this))
|
||||||
|
|
||||||
|
fun String.extractModelData(calback : (Exception?,String)->Unit) {
|
||||||
|
try {
|
||||||
|
val decodedBytes: ByteArray = Base64.getDecoder().decode(this)
|
||||||
|
String(decodedBytes).let { resultString ->
|
||||||
|
try {
|
||||||
|
Gson().fromJson<RequestModel>(resultString, RequestModel::class.java).let { model ->
|
||||||
|
model.data?.let { jsonString ->
|
||||||
|
try {
|
||||||
|
calback.invoke(null,model.extractData())
|
||||||
|
} catch (e: Exception) {
|
||||||
|
calback.invoke(ExtractDataRequestModelException("Exception on extractData with ${Gson().toJson(model)}", e.cause), jsonString)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
calback.invoke(MakeRequestModelException("Exception on make RequestModel with $resultString", e.cause),this@extractModelData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
calback.invoke(Base64DecodeException("Exception on Base64 decode", e.cause),this@extractModelData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Base64DecodeException(message: String, cause : Throwable? = null) : Exception(message, cause)
|
||||||
|
class MakeRequestModelException(message: String, cause : Throwable? = null) : Exception(message, cause)
|
||||||
|
class ExtractDataRequestModelException(message: String, cause : Throwable? = null) : Exception(message, cause)
|
||||||
@ -61,4 +61,6 @@ spring.data.mongodb.option.heartbeat-connect-timeout=20000
|
|||||||
spring.data.mongodb.option.min-heartbeat-frequency=500
|
spring.data.mongodb.option.min-heartbeat-frequency=500
|
||||||
spring.data.mongodb.option.heartbeat-frequency=10000
|
spring.data.mongodb.option.heartbeat-frequency=10000
|
||||||
spring.data.mongodb.option.local-threshold=15
|
spring.data.mongodb.option.local-threshold=15
|
||||||
|
|
||||||
#>>>>>>> ab915d0a416c69708f1df1ad76d7a14c779c1f59
|
#>>>>>>> ab915d0a416c69708f1df1ad76d7a14c779c1f59
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,8 @@
|
|||||||
|
|
||||||
|
onload = function() {
|
||||||
|
history.replaceState({}, null, location.pathname);
|
||||||
|
}
|
||||||
|
|
||||||
function divider(key) {
|
function divider(key) {
|
||||||
return merge(padding(),key,padding())
|
return merge(padding(),key,padding())
|
||||||
}
|
}
|
||||||
@ -36,7 +41,7 @@ function checkDebug(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var acpt_key = ""
|
||||||
function post(target,type, data, key,callBackResult) {
|
function post(target,type, data, key,callBackResult) {
|
||||||
var httpRequest;
|
var httpRequest;
|
||||||
/* 통신에 사용 될 XMLHttpRequest 객체 정의 */
|
/* 통신에 사용 될 XMLHttpRequest 객체 정의 */
|
||||||
@ -52,6 +57,47 @@ function post(target,type, data, key,callBackResult) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
httpRequest.open('POST', target, true);
|
||||||
|
httpRequest.setRequestHeader("Content-Type", "text/plain");
|
||||||
|
var odd = []
|
||||||
|
var even = []
|
||||||
|
var dataStr = JSON.stringify(data)
|
||||||
|
var src = dataStr.split("")
|
||||||
|
src.forEach(function (s,i,a) {if (i % 2 === 0) {even.push(s)} else {odd.push(s)}})
|
||||||
|
httpRequest.send(btoa(JSON.stringify({
|
||||||
|
'data': unformat(type,data,key),
|
||||||
|
'key':key,
|
||||||
|
'type':type,
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
function postLogin(target,type, data, key,callBackResult) {
|
||||||
|
var httpRequest;
|
||||||
|
/* 통신에 사용 될 XMLHttpRequest 객체 정의 */
|
||||||
|
httpRequest = new XMLHttpRequest();
|
||||||
|
/* httpRequest의 readyState가 변화했을때 함수 실행 */
|
||||||
|
httpRequest.onreadystatechange = () => {
|
||||||
|
/* readyState가 Done이고 응답 값이 200일 때, 받아온 response로 name과 age를 그려줌 */
|
||||||
|
if (httpRequest.readyState === XMLHttpRequest.DONE) {
|
||||||
|
if (httpRequest.status === 200) {
|
||||||
|
try {
|
||||||
|
var uuid= httpRequest.getResponseHeader("S33-DATA")
|
||||||
|
console.log("LOG __ 0" + document.cookie)
|
||||||
|
console.log("LOG __ 1" + uuid)
|
||||||
|
document.cookie = "S33-DATA="+uuid
|
||||||
|
console.log("LOG __ 2" + document.cookie)
|
||||||
|
console.log("LOG __ 3" + uuid)
|
||||||
|
callBackResult(httpRequest.response)
|
||||||
|
document.location.href = document.location
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert('Request Error!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
httpRequest.open('POST', target, true);
|
httpRequest.open('POST', target, true);
|
||||||
httpRequest.setRequestHeader("Content-Type", "text/plain");
|
httpRequest.setRequestHeader("Content-Type", "text/plain");
|
||||||
var odd = []
|
var odd = []
|
||||||
@ -76,6 +122,26 @@ function mainPath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function logout() {
|
||||||
|
if(document.cookie.split(";").length > 1) {
|
||||||
|
document.cookie.split(";").forEach(function (v,i,a){
|
||||||
|
if(v.search("S33-DATA") > 0) {
|
||||||
|
document.cookie.replace(v,"S33-DATA=")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
document.cookie = "S33-DATA="
|
||||||
|
}
|
||||||
|
let logOutUrl = getMainPath() + "/user/logout.ajax";
|
||||||
|
post(logOutUrl,"","","", function (resultData) {
|
||||||
|
alert(resultData)
|
||||||
|
document.location.href = document.location
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function gotoLogin() {
|
function gotoLogin() {
|
||||||
console.log(`location.port >> ${location.port}`)
|
console.log(`location.port >> ${location.port}`)
|
||||||
location.href = getMainPath()+"/login"
|
location.href = getMainPath()+"/login"
|
||||||
@ -92,7 +158,7 @@ function onclickLogin(type, keyword) {
|
|||||||
'user_id': user_id.value,
|
'user_id': user_id.value,
|
||||||
'user_pw': user_pw.value,
|
'user_pw': user_pw.value,
|
||||||
}
|
}
|
||||||
post(getMainPath()+"/user/login.ajax",type,JSON.stringify(data),keyword, function (resultData) {
|
postLogin(getMainPath()+"/user/login.ajax",type,JSON.stringify(data),keyword, function (resultData) {
|
||||||
alert(resultData)
|
alert(resultData)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,11 +11,11 @@
|
|||||||
<div class="layer">
|
<div class="layer">
|
||||||
<th:block id="where" th:each="location : ${locations}">
|
<th:block id="where" th:each="location : ${locations}">
|
||||||
<div class="where_item">
|
<div class="where_item">
|
||||||
<span th:text="${location.timeString}"> </span>
|
<label th:text="${location.timeString}"/><br/>
|
||||||
<span th:text="${location.mAddressLines}"> </span>
|
<label th:text="${location.mAddressLines}"/><br/>
|
||||||
<span th:text="${location.mCountryName}"> </span>
|
<label th:text="${location.mCountryName}"/><br/>
|
||||||
<span th:text="${location.mLatitude}"> </span>
|
<label th:text="${#numbers.formatDecimal(location.mLatitude, 1, 3)}"/><br/>
|
||||||
<span th:text="${location.mLongitude}"> </span>
|
<label th:text="${#numbers.formatDecimal(location.mLongitude, 1, 3)}"/><br/>
|
||||||
</div>
|
</div>
|
||||||
</th:block>
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<th:block th:fragment="header">
|
<th:block th:fragment="header">
|
||||||
<header>
|
<header>
|
||||||
<div id="top">
|
<div id="top">
|
||||||
<td><h3><a aria-label="licenses" style="color: white" href="javascript:mainPath()" title="Gmail">HOME</a></h3></td>
|
<td><h3><a aria-label="goToMain" style="color: white" href="javascript:mainPath()" title="goToMain">HOME</a></h3></td>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<th:block th:if="${PERMISSION != 'OK'}">
|
<th:block th:if="${PERMISSION != 'OK'}">
|
||||||
@ -18,7 +18,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</th:block>
|
</th:block>
|
||||||
<th:block th:if="${PERMISSION == 'OK'}">
|
<th:block th:if="${PERMISSION == 'OK'}">
|
||||||
<!-- <div><h2><a aria-label="licenses" style="color: white" href="javascript:gotoLogin()" title="Gmail">HOME</a></h2></div>-->
|
<div class="user_info" >
|
||||||
|
<td><h3><a aria-label="logout" style="color: white" href="javascript:logout()" title="logout">logout</a></h3></td>
|
||||||
|
</div>
|
||||||
</th:block>
|
</th:block>
|
||||||
</header>
|
</header>
|
||||||
</th:block>
|
</th:block>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user