update oauth2 (#84)

* update oauth2

* i18n

* fix validation

* chore: auto-fix linting and formatting issues

---------

Co-authored-by: uubulb <uubulb@users.noreply.github.com>
This commit is contained in:
UUBulb
2024-12-31 23:11:41 +08:00
committed by GitHub
parent d54372fb0c
commit 5517a8df38
8 changed files with 418 additions and 435 deletions

View File

@@ -1,4 +1,3 @@
import { oauth2callback } from "@/api/oauth2"
import { getProfile, login as loginRequest } from "@/api/user"
import { AuthContextProps } from "@/types"
import { createContext, useContext, useEffect, useMemo } from "react"
@@ -45,9 +44,8 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
}
}
const loginOauth2 = async (provider: string, state: string, code: string) => {
const loginOauth2 = async () => {
try {
await oauth2callback(provider, state, code)
const user = await getProfile()
user.role = user.role || 0
setProfile(user)