mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-04 12:26:19 +00:00
chore: update auth service
This commit is contained in:
@ -6,7 +6,6 @@ import { authServiceClient } from "@/grpcweb";
|
||||
import useWorkspaceStore from "@/stores/v1/workspace";
|
||||
import { PlanType } from "@/types/proto/api/v2/subscription_service";
|
||||
import { Role } from "@/types/proto/api/v2/user_service";
|
||||
import { removeAccessToken } from "@/utils/auth";
|
||||
import useUserStore from "../stores/v1/user";
|
||||
import AboutDialog from "./AboutDialog";
|
||||
import Icon from "./Icon";
|
||||
@ -24,7 +23,6 @@ const Header: React.FC = () => {
|
||||
|
||||
const handleSignOutButtonClick = async () => {
|
||||
await authServiceClient.signOut({});
|
||||
removeAccessToken();
|
||||
localStorage.removeItem("userId");
|
||||
window.location.href = "/auth";
|
||||
};
|
||||
|
@ -7,7 +7,6 @@ import { authServiceClient } from "@/grpcweb";
|
||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||
import useUserStore from "@/stores/v1/user";
|
||||
import useWorkspaceStore from "@/stores/v1/workspace";
|
||||
import { setAccessToken } from "@/utils/auth";
|
||||
import useLoading from "../hooks/useLoading";
|
||||
|
||||
const SignIn: React.FC = () => {
|
||||
@ -45,11 +44,9 @@ const SignIn: React.FC = () => {
|
||||
|
||||
try {
|
||||
actionBtnLoadingState.setLoading();
|
||||
const { user, accessToken } = await authServiceClient.signIn({ email, password });
|
||||
const { user } = await authServiceClient.signIn({ email, password });
|
||||
if (user) {
|
||||
userStore.setCurrentUserId(user.id);
|
||||
console.log("accessToken", accessToken);
|
||||
setAccessToken(accessToken);
|
||||
await userStore.fetchCurrentUser();
|
||||
navigateTo("/");
|
||||
} else {
|
||||
|
@ -7,7 +7,6 @@ import { authServiceClient } from "@/grpcweb";
|
||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||
import useUserStore from "@/stores/v1/user";
|
||||
import useWorkspaceStore from "@/stores/v1/workspace";
|
||||
import { setAccessToken } from "@/utils/auth";
|
||||
import useLoading from "../hooks/useLoading";
|
||||
|
||||
const SignUp: React.FC = () => {
|
||||
@ -52,14 +51,13 @@ const SignUp: React.FC = () => {
|
||||
|
||||
try {
|
||||
actionBtnLoadingState.setLoading();
|
||||
const { user, accessToken } = await authServiceClient.signUp({
|
||||
const { user } = await authServiceClient.signUp({
|
||||
email,
|
||||
nickname,
|
||||
password,
|
||||
});
|
||||
if (user) {
|
||||
userStore.setCurrentUserId(user.id);
|
||||
setAccessToken(accessToken);
|
||||
await userStore.fetchCurrentUser();
|
||||
navigateTo("/");
|
||||
} else {
|
||||
|
@ -1,9 +0,0 @@
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
export const setAccessToken = (token: string) => {
|
||||
Cookies.set("slash.access-token", token, { path: "/", expires: 365 });
|
||||
};
|
||||
|
||||
export const removeAccessToken = () => {
|
||||
Cookies.remove("slash.access-token", { path: "/", expires: 365 });
|
||||
};
|
Reference in New Issue
Block a user