优化统一登录认证

This commit is contained in:
zjl 2024-09-29 15:11:03 +08:00
parent 656c70e1d4
commit 87f02e786e
3 changed files with 6 additions and 11 deletions

View File

@ -46,16 +46,11 @@ export function login2(data) {
return http.request<BasicResponseModel>(
{
url: '/auth/oauth2/token',
// auth:{
// username:data.username,
// password:data.password
// },
method: 'POST',
data:formData,
headers: {
// "Content-Type": "application/json;charset=UTF-8",
"Content-Type": "multipart/form-data",
Authorization: "Basic YWRtaW46MTIzNDU2", // 客户端信息Base64明文mall-admin:123456
Authorization: "Basic YWRtaW46MTIzNDU2",
},
},
{

View File

@ -60,14 +60,14 @@ export const useUserStore = defineStore({
// 登录
async login(userInfo) {
try {
// const response = await login(userInfo);
const response = await login2(userInfo);
const response = await login(userInfo);
// const response = await login2(userInfo);
const {code,data } = response;
if (code === ResultEnum.SUCCESS) {
const ex = 7 * 24 * 60 * 60 * 1000;
storage.set(ACCESS_TOKEN, data.token, ex);
storage.set(ACCESS_TOKEN, data.access_token, ex);
storage.set(IS_LOCKSCREEN, false);
this.setToken(data.token);
this.setToken(data.access_token);
}
return Promise.resolve(response);
} catch (e) {

View File

@ -136,7 +136,7 @@
password:formInline.password,
code:formInline.code,
key:formInline.key,
grant_type:"password"
// grant_type:"password"
};
try {