Skip to content

Pass.muxi tech.xyz auth fix#25

Merged
zxc0328 merged 6 commits intorefactor-passfrom
pass.muxi-tech.xyz_auth_fix
Jul 6, 2021
Merged

Pass.muxi tech.xyz auth fix#25
zxc0328 merged 6 commits intorefactor-passfrom
pass.muxi-tech.xyz_auth_fix

Conversation

@qingxuanying
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/common/cookie.js Outdated
@@ -1,5 +1,6 @@
function getCookie(cname) {
let name = cname + '=';
// let name = cname;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多余的代码删掉

Comment thread src/common/service.js Outdated
Accept: 'application/json',
'Content-Type': 'application/json'
// Accept: 'application/json',
// 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

header 不用的话直接删掉就行

Comment thread src/common/service.js
// get auth-code
getOauthCode(username, password) {
return Fetch(
'/auth/api/oauth?response_type=code&client_id=51f03389-2a18-4941-ba73-c85d08201d42',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client_id 是通过参数在 URL 里面传给你的,不是写死的。

Comment thread src/common/service.js Outdated
// get auth-token
getOauthToken(aceessCode) {
let client_id = '51f03389-2a18-4941-ba73-c85d08201d42';
let client_secret = '7d52480f-730d-45a1-99cc-1397985ebe0e';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,别写死了

Comment thread src/common/service.js Outdated
//refresh-token
refreshtoken(token) {
let client_id = '51f03389-2a18-4941-ba73-c85d08201d42';
let client_secret = '7d52480f-730d-45a1-99cc-1397985ebe0e';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

别写死了

Comment thread src/pages/login/login.js Outdated
// ).then(res => {
// if (res !== null && res !== undefined) {
// let landing = 'pass.muxi-tech.xyz/';
// if (landing) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没用的代码就删掉,别注释。有用就留着。总之注释掉的代码是不好的,后面维护的人也不知道你这个代码要不要用了

Comment thread src/pages/login/login.js Outdated
});
//跳转到工作台
// let landing= getCookie('landing');
let landing = 'pass.muxi-tech.xyz/';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

landing 要从 cookie 获取。

Comment thread src/pages/login/login.js Outdated
// // landing 参数是应用登陆跳转到内网门户时加在 URL 里面的,比如:http://pass.muxixyz.com/?landing=work.muxixyz.com%2Flanding
// // 为了防止内网门户这边路由跳转时 landing 参数丢失,服务端会把 landing 放在cookie里面
// // 所以这个从 cookie 里获取 landing 然后跳转就可以

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释问题,同上。

Comment thread src/common/getFromUrl.js
}
return false;
}
export default getQueryVariable;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果复制网上的代码,也要改一下代码风格和我们自己的代码保持一致。比如用 const 和 let。var 现在基本不用了。

然后解析 query string 这个可以用这个库 https://www.npmjs.com/package/query-string。比较保险一点。你也可以去 github 上看一下这个库的源码实现。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

Comment thread src/common/service.js Outdated
getOauthToken(aceessCode) {
let client_id = '51f03389-2a18-4941-ba73-c85d08201d42';
let client_secret = '7d52480f-730d-45a1-99cc-1397985ebe0e';
let client_id = getFromUrl('client_id');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

统一在组件里解析好,调接口的时候传。不然你反复解析,做了很多无用功。

Comment thread src/pages/register/register.js Outdated
import './register.css';
import { Link } from 'react-router-dom';
import Background from '../../images/login.png';
// import Background from '../../images/login.png';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用的直接删掉

@zxc0328 zxc0328 merged commit 4f3732f into refactor-pass Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants