Pass.muxi tech.xyz auth fix#25
Merged
zxc0328 merged 6 commits intorefactor-passfrom Jul 6, 2021
Merged
Conversation
zxc0328
requested changes
Jul 2, 2021
| @@ -1,5 +1,6 @@ | |||
| function getCookie(cname) { | |||
| let name = cname + '='; | |||
| // let name = cname; | |||
| Accept: 'application/json', | ||
| 'Content-Type': 'application/json' | ||
| // Accept: 'application/json', | ||
| // 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' |
| // get auth-code | ||
| getOauthCode(username, password) { | ||
| return Fetch( | ||
| '/auth/api/oauth?response_type=code&client_id=51f03389-2a18-4941-ba73-c85d08201d42', |
Member
There was a problem hiding this comment.
client_id 是通过参数在 URL 里面传给你的,不是写死的。
| // get auth-token | ||
| getOauthToken(aceessCode) { | ||
| let client_id = '51f03389-2a18-4941-ba73-c85d08201d42'; | ||
| let client_secret = '7d52480f-730d-45a1-99cc-1397985ebe0e'; |
| //refresh-token | ||
| refreshtoken(token) { | ||
| let client_id = '51f03389-2a18-4941-ba73-c85d08201d42'; | ||
| let client_secret = '7d52480f-730d-45a1-99cc-1397985ebe0e'; |
| // ).then(res => { | ||
| // if (res !== null && res !== undefined) { | ||
| // let landing = 'pass.muxi-tech.xyz/'; | ||
| // if (landing) { |
Member
There was a problem hiding this comment.
没用的代码就删掉,别注释。有用就留着。总之注释掉的代码是不好的,后面维护的人也不知道你这个代码要不要用了
| }); | ||
| //跳转到工作台 | ||
| // let landing= getCookie('landing'); | ||
| let landing = 'pass.muxi-tech.xyz/'; |
| // // landing 参数是应用登陆跳转到内网门户时加在 URL 里面的,比如:http://pass.muxixyz.com/?landing=work.muxixyz.com%2Flanding | ||
| // // 为了防止内网门户这边路由跳转时 landing 参数丢失,服务端会把 landing 放在cookie里面 | ||
| // // 所以这个从 cookie 里获取 landing 然后跳转就可以 | ||
|
|
zxc0328
requested changes
Jul 6, 2021
| } | ||
| return false; | ||
| } | ||
| export default getQueryVariable; |
Member
There was a problem hiding this comment.
如果复制网上的代码,也要改一下代码风格和我们自己的代码保持一致。比如用 const 和 let。var 现在基本不用了。
然后解析 query string 这个可以用这个库 https://www.npmjs.com/package/query-string。比较保险一点。你也可以去 github 上看一下这个库的源码实现。
| getOauthToken(aceessCode) { | ||
| let client_id = '51f03389-2a18-4941-ba73-c85d08201d42'; | ||
| let client_secret = '7d52480f-730d-45a1-99cc-1397985ebe0e'; | ||
| let client_id = getFromUrl('client_id'); |
Member
There was a problem hiding this comment.
统一在组件里解析好,调接口的时候传。不然你反复解析,做了很多无用功。
| import './register.css'; | ||
| import { Link } from 'react-router-dom'; | ||
| import Background from '../../images/login.png'; | ||
| // import Background from '../../images/login.png'; |
zxc0328
approved these changes
Jul 6, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.