修改前端的验证码和登录相关的接口
This commit is contained in:
@ -47,16 +47,16 @@ public class CaptchaController
|
|||||||
@GetMapping("/captchaImage")
|
@GetMapping("/captchaImage")
|
||||||
public AjaxResult<Captcha> getCode(HttpServletResponse response) throws IOException
|
public AjaxResult<Captcha> getCode(HttpServletResponse response) throws IOException
|
||||||
{
|
{
|
||||||
|
AjaxResult<Captcha> ajax = AjaxResult.success();
|
||||||
Captcha captcha = new Captcha();
|
Captcha captcha = new Captcha();
|
||||||
AjaxResult<Captcha> ajax = AjaxResult.success(captcha);
|
|
||||||
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
||||||
if (!captchaEnabled)
|
captcha.setCaptchaEnabled(captchaEnabled);
|
||||||
{
|
// if (captchaEnabled)
|
||||||
|
// {
|
||||||
captcha.setCaptchaEnabled(captchaEnabled);
|
//
|
||||||
|
// }else {
|
||||||
return ajax;
|
// captcha.setCaptchaEnabled(captchaEnabled);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
String uuid = IdUtils.simpleUUID();
|
String uuid = IdUtils.simpleUUID();
|
||||||
@ -94,6 +94,7 @@ public class CaptchaController
|
|||||||
|
|
||||||
captcha.setUuid(uuid);
|
captcha.setUuid(uuid);
|
||||||
captcha.setImg(Base64.encode(os.toByteArray()));
|
captcha.setImg(Base64.encode(os.toByteArray()));
|
||||||
|
ajax.setData(captcha);
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,14 +56,14 @@ public class SysLoginController
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public AjaxResult login(@RequestBody LoginBody loginBody)
|
public AjaxResult<String> login(@RequestBody LoginBody loginBody)
|
||||||
{
|
{
|
||||||
|
|
||||||
// 生成令牌
|
// 生成令牌
|
||||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||||
loginBody.getUuid());
|
loginBody.getUuid());
|
||||||
|
|
||||||
return AjaxResult.success(token);
|
return AjaxResult.success("操作成功",token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +70,7 @@ public class AjaxResult<T>
|
|||||||
*/
|
*/
|
||||||
public static <T> AjaxResult<T> success()
|
public static <T> AjaxResult<T> success()
|
||||||
{
|
{
|
||||||
return AjaxResult.success("操作成功");
|
return AjaxResult.success("操作成功",null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,17 +83,6 @@ public class AjaxResult<T>
|
|||||||
return AjaxResult.success("操作成功", data);
|
return AjaxResult.success("操作成功", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功消息
|
|
||||||
*
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @return 成功消息
|
|
||||||
*/
|
|
||||||
public static <T> AjaxResult<T> success(String msg)
|
|
||||||
{
|
|
||||||
return AjaxResult.success(msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*
|
*
|
||||||
|
@ -49,8 +49,9 @@ const user = {
|
|||||||
const uuid = userInfo.uuid
|
const uuid = userInfo.uuid
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
login(username, password, code, uuid).then(res => {
|
login(username, password, code, uuid).then(res => {
|
||||||
setToken(res.token)
|
console.log('登录接口返回的数据'+res.data)
|
||||||
commit('SET_TOKEN', res.token)
|
setToken(res.data)
|
||||||
|
commit('SET_TOKEN', res.data)
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
@ -62,14 +63,14 @@ const user = {
|
|||||||
GetInfo({ commit, state }) {
|
GetInfo({ commit, state }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getInfo().then(res => {
|
getInfo().then(res => {
|
||||||
const user = res.user
|
const user = res.data.user
|
||||||
let avatar = user.avatar || ""
|
let avatar = user.avatar || ""
|
||||||
if (!isHttp(avatar)) {
|
if (!isHttp(avatar)) {
|
||||||
avatar = (isEmpty(avatar)) ? defAva : process.env.VUE_APP_BASE_API + avatar
|
avatar = (isEmpty(avatar)) ? defAva : process.env.VUE_APP_BASE_API + avatar
|
||||||
}
|
}
|
||||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||||
commit('SET_ROLES', res.roles)
|
commit('SET_ROLES', res.data.roles)
|
||||||
commit('SET_PERMISSIONS', res.permissions)
|
commit('SET_PERMISSIONS', res.data.permissions)
|
||||||
} else {
|
} else {
|
||||||
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
||||||
}
|
}
|
||||||
|
@ -111,10 +111,10 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
getCode() {
|
getCode() {
|
||||||
getCodeImg().then(res => {
|
getCodeImg().then(res => {
|
||||||
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
this.captchaEnabled = res.data.captchaEnabled === undefined ? true : res.data.captchaEnabled
|
||||||
if (this.captchaEnabled) {
|
if (this.captchaEnabled) {
|
||||||
this.codeUrl = "data:image/gif;base64," + res.img
|
this.codeUrl = "data:image/gif;base64," + res.data.img
|
||||||
this.loginForm.uuid = res.uuid
|
this.loginForm.uuid = res.data.uuid
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -117,8 +117,8 @@ export default {
|
|||||||
getCodeImg().then(res => {
|
getCodeImg().then(res => {
|
||||||
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
||||||
if (this.captchaEnabled) {
|
if (this.captchaEnabled) {
|
||||||
this.codeUrl = "data:image/gif;base64," + res.img
|
this.codeUrl = "data:image/gif;base64," + res.data.img
|
||||||
this.registerForm.uuid = res.uuid
|
this.registerForm.uuid = res.data.uuid
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -9,7 +9,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
|
|||||||
|
|
||||||
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
|
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
|
||||||
|
|
||||||
const baseUrl = 'http://localhost:8080' // 后端接口
|
const baseUrl = 'http://localhost:8081' // 后端接口
|
||||||
|
|
||||||
const port = process.env.port || process.env.npm_config_port || 80 // 端口
|
const port = process.env.port || process.env.npm_config_port || 80 // 端口
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user