fix: login 410 error tip
This commit is contained in:
+2
-2
@@ -5,9 +5,9 @@ export const ContentTypes = {
|
|||||||
text: "text/plain",
|
text: "text/plain",
|
||||||
markdown: "text/markdown",
|
markdown: "text/markdown",
|
||||||
file: "rustchat/file",
|
file: "rustchat/file",
|
||||||
|
archive: "rustchat/archive",
|
||||||
formData: "multipart/form-data",
|
formData: "multipart/form-data",
|
||||||
json: "application/json",
|
json: "application/json"
|
||||||
archive: "rustchat/archive"
|
|
||||||
};
|
};
|
||||||
export const firebaseConfig = {
|
export const firebaseConfig = {
|
||||||
apiKey: "AIzaSyDyJ6B1Ouenoha_gdGkBwIkBNStlwhlbO0",
|
apiKey: "AIzaSyDyJ6B1Ouenoha_gdGkBwIkBNStlwhlbO0",
|
||||||
|
|||||||
@@ -77,6 +77,18 @@ const baseQueryWithTokenCheck = async (args, api, extraOptions) => {
|
|||||||
toast.error(`${api.endpoint}: Failed to fetch`);
|
toast.error(`${api.endpoint}: Failed to fetch`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 401:
|
||||||
|
{
|
||||||
|
if (api.endpoint !== "login") {
|
||||||
|
api.dispatch(resetAuthData());
|
||||||
|
location.href = "/#/login";
|
||||||
|
toast.error("API Not Authenticated");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 403:
|
||||||
|
toast.error("Request Not Allowed");
|
||||||
|
break;
|
||||||
case 404:
|
case 404:
|
||||||
{
|
{
|
||||||
toast.error("Request Not Found");
|
toast.error("Request Not Found");
|
||||||
@@ -87,22 +99,7 @@ const baseQueryWithTokenCheck = async (args, api, extraOptions) => {
|
|||||||
toast.error(result.error.data || "Server Error");
|
toast.error(result.error.data || "Server Error");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 401:
|
|
||||||
{
|
|
||||||
if (api.endpoint !== "login") {
|
|
||||||
api.dispatch(resetAuthData());
|
|
||||||
location.href = "/#/login";
|
|
||||||
toast.error("API Not Authenticated");
|
|
||||||
}
|
|
||||||
// toast.error("token expired, please login again");
|
|
||||||
// } else {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 403:
|
|
||||||
toast.error("Request Not Allowed");
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type Props = {
|
|||||||
export default function GithubLoginButton({ type = "login", client_id }: Props) {
|
export default function GithubLoginButton({ type = "login", client_id }: Props) {
|
||||||
//拿本地存的magic token
|
//拿本地存的magic token
|
||||||
const magic_token = localStorage.getItem(KEY_LOCAL_MAGIC_TOKEN);
|
const magic_token = localStorage.getItem(KEY_LOCAL_MAGIC_TOKEN);
|
||||||
const [login, { isLoading, isSuccess }] = useLoginMutation();
|
const [login, { isLoading, isSuccess, error }] = useLoginMutation();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const query = new URLSearchParams(location.search);
|
const query = new URLSearchParams(location.search);
|
||||||
const isGithub = query.get("oauth") === "github";
|
const isGithub = query.get("oauth") === "github";
|
||||||
@@ -50,6 +50,21 @@ export default function GithubLoginButton({ type = "login", client_id }: Props)
|
|||||||
// navigateTo("/");
|
// navigateTo("/");
|
||||||
}
|
}
|
||||||
}, [isSuccess]);
|
}, [isSuccess]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (error) {
|
||||||
|
switch (error.status) {
|
||||||
|
case 410:
|
||||||
|
toast.error(
|
||||||
|
"No associated account found, please contact admin for an invitation link to join."
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
toast.error("Something Error");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}, [error]);
|
||||||
const handleGithubLogin = () => {
|
const handleGithubLogin = () => {
|
||||||
location.href = `http://github.com/login/oauth/authorize?client_id=${client_id}`;
|
location.href = `http://github.com/login/oauth/authorize?client_id=${client_id}`;
|
||||||
// console.log("github login");
|
// console.log("github login");
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const GoogleLoginButton: FC<Props> = ({ type = "login", clientId }) => {
|
const GoogleLoginButton: FC<Props> = ({ type = "login", clientId }) => {
|
||||||
const [login, { isSuccess, isLoading }] = useLoginMutation();
|
const [login, { isSuccess, isLoading, error }] = useLoginMutation();
|
||||||
//拿本地存的magic token
|
//拿本地存的magic token
|
||||||
const magic_token = localStorage.getItem(KEY_LOCAL_MAGIC_TOKEN);
|
const magic_token = localStorage.getItem(KEY_LOCAL_MAGIC_TOKEN);
|
||||||
const { signIn, loaded } = useGoogleLogin({
|
const { signIn, loaded } = useGoogleLogin({
|
||||||
@@ -56,6 +56,21 @@ const GoogleLoginButton: FC<Props> = ({ type = "login", clientId }) => {
|
|||||||
// navigateTo("/");
|
// navigateTo("/");
|
||||||
}
|
}
|
||||||
}, [isSuccess]);
|
}, [isSuccess]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (error) {
|
||||||
|
switch (error.status) {
|
||||||
|
case 410:
|
||||||
|
toast.error(
|
||||||
|
"No associated account found, please contact admin for an invitation link to join."
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
toast.error("Something Error");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}, [error]);
|
||||||
const handleGoogleLogin = () => {
|
const handleGoogleLogin = () => {
|
||||||
signIn();
|
signIn();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -70,17 +70,11 @@ export default function LoginPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log(error);
|
console.log("login err", error);
|
||||||
switch (error.status) {
|
switch (error.status) {
|
||||||
case "PARSING_ERROR":
|
|
||||||
toast.error(error.data);
|
|
||||||
break;
|
|
||||||
case 401:
|
case 401:
|
||||||
toast.error("Username or Password incorrect");
|
toast.error("Username or Password incorrect");
|
||||||
break;
|
break;
|
||||||
case 404:
|
|
||||||
toast.error("Account not exist");
|
|
||||||
break;
|
|
||||||
case 410:
|
case 410:
|
||||||
toast.error(
|
toast.error(
|
||||||
"No associated account found, please contact admin for an invitation link to join."
|
"No associated account found, please contact admin for an invitation link to join."
|
||||||
|
|||||||
Reference in New Issue
Block a user