Skip to content

Commit

Permalink
⚡ 优化 login 参数至 body
Browse files Browse the repository at this point in the history
  • Loading branch information
lbw committed Jan 28, 2024
1 parent a5a8c22 commit 0c4d077
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/api/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ export const login = (data: any) => {
if (import.meta.env.VITE_PWD_ENC_KEY) {
encPassword = other.encryption(data.password, import.meta.env.VITE_PWD_ENC_KEY);
}
const {username, randomStr, code, grant_type, scope} = data;
return request({
url: '/auth/oauth2/token',
method: 'post',
params: {username, randomStr, code, grant_type, scope},
data: {password: encPassword},
data: {...data, password: encPassword},
headers: {
skipToken: true,
Authorization: basicAuth,
Expand All @@ -50,7 +48,7 @@ export const loginByMobile = (mobile: any, code: any) => {
'Content-Type': FORM_CONTENT_TYPE,
},
method: 'post',
params: {mobile: mobile, code: code, grant_type, scope},
data: {mobile: mobile, code: code, grant_type, scope},
});
};

Expand All @@ -68,7 +66,7 @@ export const loginBySocial = (state: string, code: string) => {
'Content-Type': FORM_CONTENT_TYPE,
},
method: 'post',
params: {mobile: state + '@' + code, code: code, grant_type, scope},
data: {mobile: state + '@' + code, code: code, grant_type, scope},
});
};

Expand All @@ -93,7 +91,7 @@ export const refreshTokenApi = (refresh_token: string) => {
'Content-Type': FORM_CONTENT_TYPE,
},
method: 'post',
params: {refresh_token, grant_type, scope},
data: {refresh_token, grant_type, scope},
});
};

Expand Down Expand Up @@ -145,10 +143,10 @@ export const checkToken = (refreshTime: number, refreshLock: boolean) => {
* 获取用户信息
*/
export const getUserInfo = () => {
return request({
url: '/admin/user/info',
method: 'get',
});
return request({
url: '/admin/user/info',
method: 'get',
});
};

export const logout = () => {
Expand Down

0 comments on commit 0c4d077

Please sign in to comment.