Skip to content

Commit

Permalink
Merge pull request #214 from Authing/fix-v5-replace-graqhql-with-rest…
Browse files Browse the repository at this point in the history
…ful-get-login-status

fix: replace graphql with restful for 'check login status'
  • Loading branch information
zhaoyiming0803 committed May 12, 2023
2 parents b3139be + 0649910 commit 61d423c
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 46 deletions.
42 changes: 21 additions & 21 deletions examples/guard-react/normal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/guard-react/normal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"webpack-merge": "^4.2.1"
},
"dependencies": {
"@authing/guard-react": "^5.1.9-alpha.2",
"@authing/guard-react": "^5.1.10",
"face-api.js": "^0.22.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/guard-react/normal/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function App() {
appId="AUTHING_APP_ID"

// 如果你使用的是私有化部署的 Authing 服务,需要传入自定义 host,如:
host="https://example.authing.cn"
// host="https://example.authing.cn"

// 默认情况下,会使用你在 Authing 控制台中配置的第一个回调地址为此次认证使用的回调地址。
// 如果你配置了多个回调地址,也可以手动指定(此地址也需要加入到应用的「登录回调 URL」中):
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"packages/*"
],
"useWorkspaces": true,
"version": "5.1.9"
"version": "5.1.10"
}
2 changes: 1 addition & 1 deletion packages/guard-angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/guard-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/guard-angular",
"version": "5.1.9",
"version": "5.1.10",
"description": "Guard for Angular",
"module": "dist/fesm2015/authing-guard-angular.mjs",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -33,7 +33,7 @@
"@angular/core": "^14.0.0"
},
"dependencies": {
"@authing/guard": "^5.1.9"
"@authing/guard": "^5.1.10"
},
"author": "https://github.com/authing",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/guard-react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/guard-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/guard-react",
"version": "5.1.9",
"version": "5.1.10",
"description": "Guard for React",
"module": "dist/esm/guard.min.js",
"types": "dist/typings/index.d.ts",
Expand All @@ -24,7 +24,7 @@
"webpack": "^5.72.0"
},
"dependencies": {
"@authing/guard": "^5.1.9",
"@authing/guard": "^5.1.10",
"react": "^16.13.1"
},
"author": "https://github.com/authing",
Expand Down
2 changes: 1 addition & 1 deletion packages/guard-react18/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/guard-react18/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/guard-react18",
"version": "5.1.9",
"version": "5.1.10",
"description": "Guard for React18",
"module": "dist/esm/guard.min.js",
"types": "dist/typings/index.d.ts",
Expand All @@ -25,7 +25,7 @@
"webpack": "^5.72.0"
},
"dependencies": {
"@authing/guard-shim-react18": "^5.1.9",
"@authing/guard-shim-react18": "^5.1.10",
"react": "^18.0.0"
},
"author": "https://github.com/authing",
Expand Down
2 changes: 1 addition & 1 deletion packages/guard-shim-react18/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/guard-shim-react18/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/guard-shim-react18",
"version": "5.1.9",
"version": "5.1.10",
"description": "Guard shim for react18",
"module": "dist/esm/guard.min.js",
"types": "dist/typings/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/guard-vue2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/guard-vue2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/guard-vue2",
"version": "5.1.9",
"version": "5.1.10",
"description": "Guard for Vue2",
"module": "dist/esm/guard.min.js",
"types": "dist/typings/index.d.ts",
Expand All @@ -23,7 +23,7 @@
"webpack": "^5.72.0"
},
"dependencies": {
"@authing/guard": "^5.1.9",
"@authing/guard": "^5.1.10",
"vue": "^2.6.10"
},
"author": "https://github.com/authing",
Expand Down
2 changes: 1 addition & 1 deletion packages/guard-vue3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/guard-vue3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/guard-vue3",
"version": "5.1.9",
"version": "5.1.10",
"description": "Guard for Vue3",
"module": "dist/esm/guard.min.js",
"types": "dist/typings/index.d.ts",
Expand All @@ -24,7 +24,7 @@
"webpack": "^5.72.0"
},
"dependencies": {
"@authing/guard": "^5.1.9",
"@authing/guard": "^5.1.10",
"vue": "^3.2.37"
},
"author": "https://github.com/authing",
Expand Down
2 changes: 1 addition & 1 deletion packages/guard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/guard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/guard",
"version": "5.1.9",
"version": "5.1.10",
"description": "Guard for JS",
"module": "dist/esm/guard.min.js",
"types": "dist/typings/index.d.ts",
Expand Down
30 changes: 27 additions & 3 deletions packages/guard/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,34 @@ export class Guard {
return
}

const loginStatus: JwtTokenStatus = await authClient.checkLoginStatus(token)
const host = `${this.options.host}` || 'https://core.authing.cn'

const options: RequestInit = {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
token
})
}

try {
const fetchRes = await fetch(
`${host}/api/v2/users/login/check-status`,
options
)

const loginStatusText = await fetchRes.text()

const loginStatus: JwtTokenStatus = JSON.parse(loginStatusText)

if (loginStatus.status) {
return loginStatus
if (loginStatus.code === 200 && loginStatus.status === true) {
return loginStatus
}
} catch (e) {
return
}
}

Expand Down

0 comments on commit 61d423c

Please sign in to comment.