mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-29 03:13:41 +00:00
更新
This commit is contained in:
@@ -13,7 +13,6 @@ const glob = {
|
||||
getToken() {
|
||||
//token名称
|
||||
const TOKEN_NAME = 'token';
|
||||
console.log(TOKEN_NAME, $cookies.get(this.TOKEN_NAME));
|
||||
//返回TOKEN
|
||||
return $cookies.get(this.TOKEN_NAME);
|
||||
},
|
||||
|
||||
@@ -71,6 +71,7 @@ public class CommonUtil {
|
||||
public static void setCookie(HttpServletResponse httpServletResponse, String name, String value) {
|
||||
Cookie cookie = new Cookie(name, value);
|
||||
cookie.setPath("/");
|
||||
cookie.setHttpOnly(false);
|
||||
httpServletResponse.addCookie(cookie);
|
||||
}
|
||||
|
||||
|
||||
+3
-7
@@ -1,6 +1,7 @@
|
||||
package org.itkk.udf.api.rbac.web;
|
||||
|
||||
import org.itkk.udf.api.common.CommonConstant;
|
||||
import org.itkk.udf.api.common.CommonUtil;
|
||||
import org.itkk.udf.api.rbac.dto.LoginDto;
|
||||
import org.itkk.udf.api.rbac.dto.RegisteredDto;
|
||||
import org.itkk.udf.api.rbac.service.UserService;
|
||||
@@ -11,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@@ -40,9 +40,7 @@ public class UserPublicController {
|
||||
@PostMapping("login")
|
||||
public RestResponse<String> login(@RequestBody @Valid LoginDto loginDto) {
|
||||
final String token = userService.login(loginDto);
|
||||
Cookie cookie = new Cookie(CommonConstant.PARAMETER_NAME_TOKEN, token);
|
||||
cookie.setPath("/");
|
||||
httpServletResponse.addCookie(cookie);
|
||||
CommonUtil.setCookie(httpServletResponse,CommonConstant.PARAMETER_NAME_TOKEN,token);
|
||||
return new RestResponse<>(token);
|
||||
}
|
||||
|
||||
@@ -55,9 +53,7 @@ public class UserPublicController {
|
||||
@PostMapping("registered")
|
||||
public RestResponse<String> registered(@RequestBody @Valid RegisteredDto registeredDto) {
|
||||
final String token = userService.registered(registeredDto);
|
||||
Cookie cookie = new Cookie(CommonConstant.PARAMETER_NAME_TOKEN, token);
|
||||
cookie.setPath("/");
|
||||
httpServletResponse.addCookie(cookie);
|
||||
CommonUtil.setCookie(httpServletResponse,CommonConstant.PARAMETER_NAME_TOKEN,token);
|
||||
return new RestResponse<>(token);
|
||||
}
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@
|
||||
position: inherit;
|
||||
}
|
||||
|
||||
.pre-scrollable{
|
||||
.pre-scrollable {
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -533,34 +533,6 @@
|
||||
$('.custom-loadding')[0].remove();
|
||||
}
|
||||
}
|
||||
|
||||
//写cookies
|
||||
function setCookie(name, value) {
|
||||
var Days = 30;
|
||||
var exp = new Date();
|
||||
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
|
||||
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
|
||||
}
|
||||
|
||||
//读取cookies
|
||||
function getCookie(name) {
|
||||
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
|
||||
if (arr === document.cookie.match(reg)) {
|
||||
return unescape(arr[2]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//删除cookies
|
||||
function delCookie(name) {
|
||||
var exp = new Date();
|
||||
exp.setTime(exp.getTime() - 1);
|
||||
var cval = getCookie(name);
|
||||
if (cval != null) {
|
||||
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user