|
@@ -1,5 +1,6 @@
|
|
|
package com.gxzc.zen.web.sys.controller
|
|
|
|
|
|
+import com.baomidou.kisso.SSOConfig
|
|
|
import com.baomidou.kisso.SSOHelper
|
|
|
import com.baomidou.kisso.annotation.Action
|
|
|
import com.baomidou.kisso.annotation.Login
|
|
@@ -8,7 +9,7 @@ import com.baomidou.kisso.security.token.SSOToken
|
|
|
import com.gxzc.zen.api.sys.service.ISysUserService
|
|
|
import com.gxzc.zen.common.base.BaseController
|
|
|
import com.gxzc.zen.common.dto.RequestDto
|
|
|
-import com.gxzc.zen.common.dto.ResultDto
|
|
|
+import com.gxzc.zen.common.dto.ResponseDto
|
|
|
import com.gxzc.zen.common.exception.ZenException
|
|
|
import com.gxzc.zen.common.exception.ZenExceptionEnum
|
|
|
import io.swagger.annotations.ApiOperation
|
|
@@ -40,6 +41,7 @@ class AuthController : BaseController() {
|
|
|
// 验证输入合法性
|
|
|
val account = data.data["account"]?.toString()?.trim()
|
|
|
val password = data.data["password"]?.toString()
|
|
|
+ val rememberMe = data.data["rememberMe"] as Boolean
|
|
|
|
|
|
if (account.isNullOrEmpty() || password.isNullOrEmpty()) {
|
|
|
throw ZenException(ZenExceptionEnum.REQUEST_NULL)
|
|
@@ -53,16 +55,19 @@ class AuthController : BaseController() {
|
|
|
}
|
|
|
|
|
|
// 生成登陆 token->cookie
|
|
|
+ if (rememberMe) {
|
|
|
+ SSOConfig.getInstance().cookieMaxage = 604800
|
|
|
+ }
|
|
|
SSOHelper.setCookie(getRequest(), getResponse(), SSOToken.create().setId(user.id), true)
|
|
|
|
|
|
// redirectURL
|
|
|
- return ResponseEntity.ok(ResultDto(200, "success", data.data["redirectURL"]))
|
|
|
+ return ResponseEntity.ok(null)
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "登出")
|
|
|
@DeleteMapping("/logout")
|
|
|
fun logout(): ResponseEntity<*> {
|
|
|
- SSOHelper.logout(getRequest(), getResponse())
|
|
|
+ SSOHelper.clearLogin(getRequest(), getResponse())
|
|
|
return ResponseEntity.ok(null)
|
|
|
}
|
|
|
}
|