diff --git a/cmd/server/api/rpc_logout_user.go b/cmd/server/api/rpc_logout_user.go index 36dd65f..586ace0 100644 --- a/cmd/server/api/rpc_logout_user.go +++ b/cmd/server/api/rpc_logout_user.go @@ -25,6 +25,7 @@ func (s *Server) LogoutUser(ctx context.Context, req *pb.LogoutUserRequest) (*pb return nil, status.Errorf(codes.Internal, "failed to get user: %v", err) } + log.Info("logout user", "user", u.ID, "session", req.SessionId) sessionId, err := uuid.Parse(req.SessionId) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "invalid session id") diff --git a/cmd/server/docs/swagger/tlz.swagger.json b/cmd/server/docs/swagger/tlz.swagger.json index 2324701..e1b0fd9 100644 --- a/cmd/server/docs/swagger/tlz.swagger.json +++ b/cmd/server/docs/swagger/tlz.swagger.json @@ -226,10 +226,12 @@ }, "parameters": [ { - "name": "sessionId", - "in": "query", - "required": false, - "type": "string" + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbLogoutUserRequest" + } } ], "tags": [ @@ -529,6 +531,14 @@ } } }, + "pbLogoutUserRequest": { + "type": "object", + "properties": { + "sessionId": { + "type": "string" + } + } + }, "pbNamespace": { "type": "object", "properties": { diff --git a/cmd/server/web/src/components/require-auth.tsx b/cmd/server/web/src/components/require-auth.tsx index cf43612..279e1d8 100644 --- a/cmd/server/web/src/components/require-auth.tsx +++ b/cmd/server/web/src/components/require-auth.tsx @@ -10,9 +10,6 @@ const RequireAuth = ({ allowedRoles }: RequireAuthProps): ReactElement | null => const { auth } = useAuth(); const location = useLocation(); - console.log("RequireAuth: auth", auth); - console.log("RequireAuth: allowedRoles", allowedRoles); - // If the user is not authenticated, redirect to login if (!auth?.user) { return ; diff --git a/cmd/server/web/src/components/ui/user-nav.tsx b/cmd/server/web/src/components/ui/user-nav.tsx index 2766c1d..f527c48 100644 --- a/cmd/server/web/src/components/ui/user-nav.tsx +++ b/cmd/server/web/src/components/ui/user-nav.tsx @@ -14,7 +14,7 @@ import { DropdownMenuTrigger, } from "./dropdown-menu"; import {useContext} from "react"; -import AuthContext from "@/context/auth-provider.tsx"; +import AuthContext, {Auth} from "@/context/auth-provider.tsx"; import {useNavigate} from "react-router-dom"; import axios from "@/api/axios.ts"; @@ -24,28 +24,35 @@ export function UserNav() { const logout = async () => { try { - axios.post('/api/v1/logout', { - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + localStorage.getItem('token') + const savedAuthData = localStorage.getItem('authData'); + const authData: Auth = JSON.parse(savedAuthData); + const accessToken = authData ? authData.access_token : ''; + + const response = await axios.post('/api/v1/logout_user', + { + session_id: authData?.session_id }, - }).then((response) => { - if (response.status >= 200 && response.status < 300) { - // Clearing the authentication context - if (setAuth) { - setAuth(undefined); + { + headers: { + Authorization: `Bearer ${accessToken}`, // Authorization header } - } else { - console.error(response) - } - }); + }); + + if (response.status === 200) { + // Clearing auth data from localStorage and context + localStorage.removeItem('authData'); - navigate('/'); + // Redirect to the login page or another page as per your application flow + location.href = '/login'; + } else { + // Handle unsuccessful logout attempt + localStorage.removeItem('authData'); + console.error('Logout failed:', response); + } } catch (error) { - // TODO: Handle error, e.g., show a notification to the user - console.error("An error occurred during logout:", error); + console.error('An error occurred during logout:', error); } - }; + } return ( diff --git a/cmd/server/web/src/context/auth-provider.tsx b/cmd/server/web/src/context/auth-provider.tsx index baf625e..84fc292 100644 --- a/cmd/server/web/src/context/auth-provider.tsx +++ b/cmd/server/web/src/context/auth-provider.tsx @@ -2,12 +2,12 @@ import {createContext, Dispatch, PropsWithChildren, SetStateAction, useMemo, use interface AuthContextProps { auth?: Auth; - setAuth?: Dispatch>; + setAuth?: Dispatch>; } const AuthContext = createContext({}); -type User = { +export type User = { id: string; username: string; full_name: string; @@ -16,8 +16,9 @@ type User = { created_at: string; } -type Auth = { +export type Auth = { user: User; + session_id: string; access_token: string; refresh_token: string; access_token_expires_at: string; @@ -25,7 +26,11 @@ type Auth = { } export const AuthProvider = ({ children }: PropsWithChildren<{}>) => { - const [auth, setAuth] = useState(); + // Loading auth data from localStorage + const savedAuthData = localStorage.getItem('authData'); + const initialAuth: Auth = savedAuthData ? JSON.parse(savedAuthData) : undefined; + + const [auth, setAuth] = useState(initialAuth); const value = useMemo(() => ({ auth, setAuth }), [auth, setAuth]); diff --git a/cmd/server/web/src/hooks/use-refresh-token.ts b/cmd/server/web/src/hooks/use-refresh-token.ts index 531644d..70b1064 100644 --- a/cmd/server/web/src/hooks/use-refresh-token.ts +++ b/cmd/server/web/src/hooks/use-refresh-token.ts @@ -10,8 +10,6 @@ const useRefreshToken = () => { }); if (setAuth) { setAuth((prev: any) => { - console.log(JSON.stringify(prev)); - console.log(response.data.accessToken); return {...prev, accessToken: response.data.accessToken} }); } diff --git a/cmd/server/web/src/pages/login/components/user-login-form.tsx b/cmd/server/web/src/pages/login/components/user-login-form.tsx index 2054fe0..e16b1d0 100644 --- a/cmd/server/web/src/pages/login/components/user-login-form.tsx +++ b/cmd/server/web/src/pages/login/components/user-login-form.tsx @@ -5,9 +5,10 @@ import {Button} from "@/components/ui/button" import {Input} from "@/components/ui/input" import {Label} from "@/components/ui/label" import {Icons} from "@/components/ui/icons.tsx"; -import {SyntheticEvent, useState} from "react"; +import {SyntheticEvent, useEffect, useState} from "react"; import {useLocation, useNavigate} from "react-router-dom"; import useAuth from "@/hooks/use-auth.ts"; +import {Auth} from "@/context/auth-provider.tsx"; interface UserLoginFormProps extends React.HTMLAttributes { } @@ -21,7 +22,7 @@ export function UserLoginForm({className, ...props}: UserLoginFormProps) { const [username, setUsername] = useState("") const [password, setPassword] = useState("") - const {setAuth} = useAuth(); + const {auth, setAuth} = useAuth(); const onSubmit = async (event: SyntheticEvent) => { event.preventDefault() @@ -51,8 +52,26 @@ export function UserLoginForm({className, ...props}: UserLoginFormProps) { if (response.ok) { response.json().then((data) => { + let auth: Auth = { + user: { + id: data?.user?.id, + username: data?.user?.username, + full_name: data?.user?.full_name, + role: data?.user?.role, + password_changed_at: data?.user?.password_changed_at, + created_at: data?.user?.created_at, + }, + session_id: data?.session_id, + access_token: data?.access_token, + refresh_token: data?.refresh_token, + access_token_expires_at: data?.access_token_expires_at, + refresh_token_expires_at: data?.refresh_token_expires_at, + } + + // Setting the authentication context if (setAuth) { - setAuth(data) + setAuth(auth); + localStorage.setItem('authData', JSON.stringify(auth)); } }); navigate(from, { replace: true }); @@ -60,11 +79,17 @@ export function UserLoginForm({className, ...props}: UserLoginFormProps) { }).catch((error) => { console.error(error) + }).finally(() => { + setIsLoading(false) }) - - setIsLoading(false) } + useEffect(() => { + if (auth?.user) { + navigate(from, { replace: true }); + } + }); + return (
diff --git a/cmd/server/web/src/pages/register/components/user-register-form.tsx b/cmd/server/web/src/pages/register/components/user-register-form.tsx index 32a8a39..ed6d70b 100644 --- a/cmd/server/web/src/pages/register/components/user-register-form.tsx +++ b/cmd/server/web/src/pages/register/components/user-register-form.tsx @@ -1,169 +1,179 @@ import * as React from "react" -import {useState} from "react" +import {useEffect, useState} from "react" import {cn} from "@/lib/utils" import {Button} from "@/components/ui/button" import {Input} from "@/components/ui/input" import {Label} from "@/components/ui/label" import {Icons} from "@/components/ui/icons.tsx"; -import {useNavigate} from "react-router-dom"; +import {useLocation, useNavigate} from "react-router-dom"; import {AlertTriangle} from "lucide-react"; +import useAuth from "@/hooks/use-auth.ts"; interface UserRegisterFormProps extends React.HTMLAttributes { } export function UserRegisterForm({className, ...props}: UserRegisterFormProps) { - const [isLoading, setIsLoading] = useState(false) - const navigate = useNavigate() - const [errors, setErrors] = useState([]) - const [name, setName] = useState("") - const [email, setEmail] = useState("") - const [password, setPassword] = useState("") + const [isLoading, setIsLoading] = useState(false) + const navigate = useNavigate(); + const location = useLocation(); + const from = location.state?.from?.pathname || "/"; + const [errors, setErrors] = useState([]) + const [name, setName] = useState("") + const [email, setEmail] = useState("") + const [password, setPassword] = useState("") + const {auth, setAuth} = useAuth(); - async function onSubmit(event: React.SyntheticEvent) { - event.preventDefault() - setIsLoading(true) + async function onSubmit(event: React.SyntheticEvent) { + event.preventDefault() + setIsLoading(true) - setErrors([]) + setErrors([]) - setTimeout(() => { - setIsLoading(false) - }, 3000) + setTimeout(() => { + setIsLoading(false) + }, 3000) - let request = { - full_name: name, - username: email, - email: email, - password: password - } - - await fetch('http://localhost:8000/api/v1/create_user', { - method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify(request), - }).then((response) => { - if (!response.ok) { - response.json().then((data) => { - let responseErrors = [] - let details = data?.details - for (let key in details) { - for (let violation of details[key]?.field_violations) { - responseErrors.push(violation?.field + ": " + violation?.description) - } - } - setErrors(responseErrors) - }) - } + let request = { + full_name: name, + username: email, + email: email, + password: password + } - if (response.ok) { - navigate('/login') + await fetch('http://localhost:8000/api/v1/create_user', { + method: 'POST', + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify(request), + }).then((response) => { + if (!response.ok) { + response.json().then((data) => { + let responseErrors = [] + let details = data?.details + for (let key in details) { + for (let violation of details[key]?.field_violations) { + responseErrors.push(violation?.field + ": " + violation?.description) } - }).catch((error) => { - console.log(error) + } + setErrors(responseErrors) }) + } + + if (response.ok) { + navigate('/login') + } + }).catch((error) => { + console.log(error) + }) + } + + useEffect(() => { + if (auth?.user) { + navigate(from, {replace: true}); } + }); - return ( -
-
-

- Create an account -

-

- Enter your email below to create your account -

-
-
-
-
- - setName(e.target.value)} - /> - - setEmail(e.target.value)} - /> - - setPassword(e.target.value)} - /> -
-
- {errors?.length > 0 && ( -
-
- -
-
- {errors.map((error, i) => ( - {error} - ))} -
-
- )} -
- + return ( +
+
+

+ Create an account +

+

+ Enter your email below to create your account +

+
+ +
+
+ + setName(e.target.value)} + /> + + setEmail(e.target.value)} + /> + + setPassword(e.target.value)} + /> +
+
+ {errors?.length > 0 && ( +
+
+
- -
-
- +
+ {errors.map((error, i) => ( + {error} + ))}
-
+
+ )} +
+ +
+ +
+
+ +
+
Or continue with -
-
- -
- ) +
+ + +
+ ) } diff --git a/pb/service_tlz.pb.go b/pb/service_tlz.pb.go index 19491ac..993bb21 100644 --- a/pb/service_tlz.pb.go +++ b/pb/service_tlz.pb.go @@ -47,7 +47,7 @@ var file_service_tlz_proto_rawDesc = []byte{ 0x74, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0e, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0b, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, - 0xd1, 0x0b, 0x0a, 0x03, 0x54, 0x6c, 0x7a, 0x12, 0x80, 0x01, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, + 0xd4, 0x0b, 0x0a, 0x03, 0x54, 0x6c, 0x7a, 0x12, 0x80, 0x01, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, @@ -84,70 +84,70 @@ var file_service_tlz_proto_rawDesc = []byte{ 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x27, 0x73, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x20, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x1a, 0x1d, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x27, 0x73, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x20, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x6e, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x55, 0x73, + 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x71, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x22, 0x3e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x22, 0x0f, 0x2f, 0x76, - 0x31, 0x2f, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x92, 0x41, 0x24, - 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0d, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x20, 0x61, - 0x20, 0x75, 0x73, 0x65, 0x72, 0x1a, 0x0d, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x20, 0x61, 0x20, - 0x75, 0x73, 0x65, 0x72, 0x12, 0x69, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, - 0x12, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x14, 0x2e, 0x70, 0x62, - 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x3c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x67, - 0x65, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x92, 0x41, 0x24, 0x0a, 0x04, 0x55, 0x73, 0x65, - 0x72, 0x12, 0x0d, 0x47, 0x65, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x75, 0x73, 0x65, 0x72, 0x73, - 0x1a, 0x0d, 0x47, 0x65, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, - 0x88, 0x01, 0x0a, 0x0b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, - 0x16, 0x2e, 0x70, 0x62, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x6d, 0x61, 0x69, 0x6c, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x62, 0x2e, 0x56, 0x65, 0x72, - 0x69, 0x66, 0x79, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x48, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x65, - 0x72, 0x69, 0x66, 0x79, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x92, 0x41, 0x2d, 0x12, 0x0c, 0x56, - 0x65, 0x72, 0x69, 0x66, 0x79, 0x20, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x1a, 0x1d, 0x56, 0x65, 0x72, - 0x69, 0x66, 0x79, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x27, 0x73, 0x20, 0x65, 0x6d, 0x61, - 0x69, 0x6c, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x5f, 0x0a, 0x04, 0x50, 0x69, - 0x6e, 0x67, 0x12, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x10, 0x2e, - 0x70, 0x62, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x3a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x69, 0x6e, - 0x67, 0x92, 0x41, 0x27, 0x0a, 0x03, 0x4f, 0x70, 0x73, 0x12, 0x0f, 0x50, 0x69, 0x6e, 0x67, 0x20, - 0x74, 0x68, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x1a, 0x0f, 0x50, 0x69, 0x6e, 0x67, - 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x97, 0x01, 0x0a, 0x0c, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x17, 0x2e, 0x70, - 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x54, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x3a, 0x01, 0x2a, 0x92, 0x41, 0x35, - 0x12, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x64, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x1e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, - 0x6e, 0x65, 0x77, 0x20, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, - 0x20, 0x75, 0x73, 0x65, 0x72, 0x12, 0x70, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x73, 0x12, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, - 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, - 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x92, - 0x41, 0x25, 0x12, 0x0b, 0x47, 0x65, 0x74, 0x20, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x1a, - 0x16, 0x47, 0x65, 0x74, 0x20, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x20, 0x66, 0x6f, 0x72, - 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x12, 0xa9, 0x01, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1a, 0x2e, 0x70, 0x62, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x5d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x22, 0x14, 0x2f, 0x76, - 0x31, 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x3a, 0x01, 0x2a, 0x92, 0x41, 0x3b, 0x12, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x20, 0x61, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x1a, 0x21, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20, 0x75, - 0x73, 0x65, 0x72, 0x42, 0x64, 0x5a, 0x15, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x7a, 0x63, 0x75, 0x62, 0x62, 0x73, 0x2f, 0x74, 0x6c, 0x7a, 0x92, 0x41, 0x4a, 0x12, - 0x48, 0x0a, 0x07, 0x54, 0x4c, 0x5a, 0x20, 0x41, 0x50, 0x49, 0x22, 0x36, 0x0a, 0x07, 0x54, 0x4c, - 0x5a, 0x20, 0x41, 0x50, 0x49, 0x12, 0x1d, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x7a, 0x63, 0x75, 0x62, 0x62, 0x73, - 0x2f, 0x74, 0x6c, 0x7a, 0x1a, 0x0c, 0x7a, 0x63, 0x75, 0x62, 0x62, 0x73, 0x40, 0x70, 0x6d, 0x2e, - 0x6d, 0x65, 0x32, 0x05, 0x30, 0x2e, 0x31, 0x2e, 0x30, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x6d, 0x70, 0x74, 0x79, 0x22, 0x41, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x22, 0x0f, 0x2f, 0x76, + 0x31, 0x2f, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x3a, 0x01, 0x2a, + 0x92, 0x41, 0x24, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0d, 0x4c, 0x6f, 0x67, 0x6f, 0x75, + 0x74, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x1a, 0x0d, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, + 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x12, 0x69, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x73, 0x12, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x14, + 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x76, + 0x31, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x92, 0x41, 0x24, 0x0a, 0x04, + 0x55, 0x73, 0x65, 0x72, 0x12, 0x0d, 0x47, 0x65, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x75, 0x73, + 0x65, 0x72, 0x73, 0x1a, 0x0d, 0x47, 0x65, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x75, 0x73, 0x65, + 0x72, 0x73, 0x12, 0x88, 0x01, 0x0a, 0x0b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x6d, 0x61, + 0x69, 0x6c, 0x12, 0x16, 0x2e, 0x70, 0x62, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x6d, + 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x62, 0x2e, + 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x48, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, + 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x92, 0x41, 0x2d, + 0x12, 0x0c, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x20, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x1a, 0x1d, + 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x27, 0x73, 0x20, + 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x5f, 0x0a, + 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x1a, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x3a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x76, 0x31, 0x2f, + 0x70, 0x69, 0x6e, 0x67, 0x92, 0x41, 0x27, 0x0a, 0x03, 0x4f, 0x70, 0x73, 0x12, 0x0f, 0x50, 0x69, + 0x6e, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x1a, 0x0f, 0x50, + 0x69, 0x6e, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x97, + 0x01, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, + 0x17, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x54, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x3a, 0x01, 0x2a, + 0x92, 0x41, 0x35, 0x12, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x6e, 0x65, + 0x77, 0x20, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x1e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x20, 0x61, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x66, 0x6f, + 0x72, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x12, 0x70, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x44, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x12, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x1a, 0x16, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3f, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x11, 0x12, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x73, 0x92, 0x41, 0x25, 0x12, 0x0b, 0x47, 0x65, 0x74, 0x20, 0x64, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x73, 0x1a, 0x16, 0x47, 0x65, 0x74, 0x20, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x12, 0xa9, 0x01, 0x0a, 0x0f, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1a, + 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x5d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x22, + 0x14, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x3a, 0x01, 0x2a, 0x92, 0x41, 0x3b, 0x12, 0x16, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x1a, 0x21, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x6e, 0x65, + 0x77, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, + 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x42, 0x64, 0x5a, 0x15, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x7a, 0x63, 0x75, 0x62, 0x62, 0x73, 0x2f, 0x74, 0x6c, 0x7a, 0x92, + 0x41, 0x4a, 0x12, 0x48, 0x0a, 0x07, 0x54, 0x4c, 0x5a, 0x20, 0x41, 0x50, 0x49, 0x22, 0x36, 0x0a, + 0x07, 0x54, 0x4c, 0x5a, 0x20, 0x41, 0x50, 0x49, 0x12, 0x1d, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, + 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x7a, 0x63, 0x75, + 0x62, 0x62, 0x73, 0x2f, 0x74, 0x6c, 0x7a, 0x1a, 0x0c, 0x7a, 0x63, 0x75, 0x62, 0x62, 0x73, 0x40, + 0x70, 0x6d, 0x2e, 0x6d, 0x65, 0x32, 0x05, 0x30, 0x2e, 0x31, 0x2e, 0x30, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var file_service_tlz_proto_goTypes = []interface{}{ diff --git a/pb/service_tlz.pb.gw.go b/pb/service_tlz.pb.gw.go index 14d34ba..19bad0a 100644 --- a/pb/service_tlz.pb.gw.go +++ b/pb/service_tlz.pb.gw.go @@ -167,18 +167,15 @@ func local_request_Tlz_RefreshToken_0(ctx context.Context, marshaler runtime.Mar } -var ( - filter_Tlz_LogoutUser_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - func request_Tlz_LogoutUser_0(ctx context.Context, marshaler runtime.Marshaler, client TlzClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq LogoutUserRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Tlz_LogoutUser_0); err != nil { + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -191,10 +188,11 @@ func local_request_Tlz_LogoutUser_0(ctx context.Context, marshaler runtime.Marsh var protoReq LogoutUserRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Tlz_LogoutUser_0); err != nil { + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } diff --git a/proto/service_tlz.proto b/proto/service_tlz.proto index 1e82e66..1e87c63 100644 --- a/proto/service_tlz.proto +++ b/proto/service_tlz.proto @@ -77,6 +77,7 @@ service Tlz { rpc LogoutUser(LogoutUserRequest) returns (Empty) { option (google.api.http) = { post: "/v1/logout_user" + body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "User"