优化统一登录认证
This commit is contained in:
parent
656c70e1d4
commit
87f02e786e
@ -46,16 +46,11 @@ export function login2(data) {
|
|||||||
return http.request<BasicResponseModel>(
|
return http.request<BasicResponseModel>(
|
||||||
{
|
{
|
||||||
url: '/auth/oauth2/token',
|
url: '/auth/oauth2/token',
|
||||||
// auth:{
|
|
||||||
// username:data.username,
|
|
||||||
// password:data.password
|
|
||||||
// },
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data:formData,
|
data:formData,
|
||||||
headers: {
|
headers: {
|
||||||
// "Content-Type": "application/json;charset=UTF-8",
|
|
||||||
"Content-Type": "multipart/form-data",
|
"Content-Type": "multipart/form-data",
|
||||||
Authorization: "Basic YWRtaW46MTIzNDU2", // 客户端信息Base64明文:mall-admin:123456
|
Authorization: "Basic YWRtaW46MTIzNDU2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -60,14 +60,14 @@ export const useUserStore = defineStore({
|
|||||||
// 登录
|
// 登录
|
||||||
async login(userInfo) {
|
async login(userInfo) {
|
||||||
try {
|
try {
|
||||||
// const response = await login(userInfo);
|
const response = await login(userInfo);
|
||||||
const response = await login2(userInfo);
|
// const response = await login2(userInfo);
|
||||||
const {code,data } = response;
|
const {code,data } = response;
|
||||||
if (code === ResultEnum.SUCCESS) {
|
if (code === ResultEnum.SUCCESS) {
|
||||||
const ex = 7 * 24 * 60 * 60 * 1000;
|
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);
|
storage.set(IS_LOCKSCREEN, false);
|
||||||
this.setToken(data.token);
|
this.setToken(data.access_token);
|
||||||
}
|
}
|
||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -136,7 +136,7 @@
|
|||||||
password:formInline.password,
|
password:formInline.password,
|
||||||
code:formInline.code,
|
code:formInline.code,
|
||||||
key:formInline.key,
|
key:formInline.key,
|
||||||
grant_type:"password"
|
// grant_type:"password"
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user