Skip to content

Commit

Permalink
Fix with platform
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy committed Sep 9, 2024
1 parent 8ebe647 commit 25c4ebe
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/apis/auth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as UserServiceModel from "@/models/service/user";
import { axiosClient } from "@/utils/axiosClient";

export async function postLogin(account: string, password: string) {
let res = await axiosClient.post<void>("/api/v1/user/login", {
export async function postPasswordLogin(account: string, password: string) {
let res = await axiosClient.post<void>("/auth/password", {
account: account,
password: password,
});
Expand Down Expand Up @@ -31,5 +31,5 @@ export async function getCurrentUser(): Promise<UserServiceModel.UserInfo> {
}

export function redirectToOAuthGitHub() {
window.location.href = "/api/v1/oauth/github";
window.location.href = "/auth/github";
}
2 changes: 1 addition & 1 deletion src/components/display/ProblemTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const ProblemTable: React.FC<ProblemTableProps> = (props) => {
</td>
<td>
<span className="text-xs">
{problemInfo.passRate.toFixed(2)}%
{problemInfo.passRate?.toFixed(2)}%
</span>
</td>
{props.showActions && (
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/handlers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const getCurrentUser = http.get("/api/v1/user/current", (info) => {
});
});

export const postLogin = http.post("/api/v1/user/login", async (info) => {
export const postPasswordLogin = http.post("/auth/password", async (info) => {
const body = await info.request.json();
const { account } = body?.valueOf() as {
account: string;
Expand Down
8 changes: 6 additions & 2 deletions src/mocks/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import {
deleteProblem,
putProblemPackage,
} from "./handlers/problem";
import { getCurrentUser, postLogin, postSignOut } from "./handlers/user";
import {
getCurrentUser,
postPasswordLogin,
postSignOut,
} from "./handlers/user";
import { getRankList } from "./handlers/rank";

const restHandlers = [
getCurrentUser,
postLogin,
postPasswordLogin,
postSignOut,
putProblem,
getProblemInfo,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { redirectToOAuthGitHub, postLogin } from "@/apis/auth";
import { redirectToOAuthGitHub, postPasswordLogin } from "@/apis/auth";
import GitHubIcon from "@/components/display/icons/GitHubIcon";
import EyeIcon from "@/components/display/icons/tabler/EyeIcon";
import EyeClosedIcon from "@/components/display/icons/tabler/EyeClosedIcon";
Expand Down Expand Up @@ -85,7 +85,7 @@ const Login: React.FC = () => {
className="btn btn-neutral btn-active btn-block"
type="submit"
onClick={() => {
postLogin(account, password).then((res) => {
postPasswordLogin(account, password).then((res) => {
console.log(res);
window.location.href = import.meta.env.BASE_URL;
});
Expand Down
5 changes: 5 additions & 0 deletions vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const viteConfig = ({ mode }) => {
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\/v1/, ""),
},
"/auth": {
target: "http://localhost:8080/auth",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/auth/, ""),
},
},
},
base: isGhPagesBuild ? "/frontend/" : "/",
Expand Down

0 comments on commit 25c4ebe

Please sign in to comment.