Skip to content

Commit

Permalink
Merge pull request #111 from bas-kirill/feature/logout
Browse files Browse the repository at this point in the history
feat(logout): add logout button and server side processing
  • Loading branch information
bas-kirill authored Aug 25, 2024
2 parents d4ac521 + a8c1778 commit 04f3357
Show file tree
Hide file tree
Showing 35 changed files with 602 additions and 107 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://www.figma.com/design/Kskaw5xH0D8rsljazkXmFL/Muse-Project?node-id=0-1&t=v

🛠Tech Stack: Kotlin, Spring Boot, Gradle, PostgreSQL

🔄DevOps: Docker, Docker Compose, Testcontainers, GitHub CI/CD (Self-Hosted Runners), GitGuardian
🔄DevOps: Docker, Docker Compose, TestcЩontainers, GitHub CI/CD (Self-Hosted Runners), GitGuardian

🏛️Arch: Clean Architecture, DDD, Feature Slicing, REST, TDD, Service Based, ArchUnit, Monorepository

Expand Down
8 changes: 2 additions & 6 deletions client/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
RouterProvider,
} from "react-router-dom";
import { HomePage } from "pages/home";
import { UserProfilePage, loader as profileLoader } from "pages/profile";
import { ProfilePage, loader as profileLoader } from "pages/profile";
import { CataloguePage, loader as catalogueLoader } from "pages/catalogue";
import {
action as loginAction,
Expand Down Expand Up @@ -49,11 +49,7 @@ import { FavoritePage, loader as favoriteLoader } from "pages/favorite";
const routes = createRoutesFromElements(
<Route>
<Route path={HOME} element={<HomePage />} />
<Route
path={PROFILE}
element={<UserProfilePage />}
loader={profileLoader}
/>
<Route path={PROFILE} element={<ProfilePage />} loader={profileLoader} />
<Route
path={CATALOGUE}
element={<CataloguePage />}
Expand Down
15 changes: 7 additions & 8 deletions client/src/domain/model/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { jwtDecode } from "jwt-decode";
import { Role } from "./role";
import { Cookies } from "typescript-cookie";
import { COOKIE_JWT_KEY } from "shared/config/frontend";
import { deleteCookie, getCookie } from "shared/cookie/cookie";

interface JwtPayload {
sub: string;
Expand All @@ -10,8 +11,6 @@ interface JwtPayload {
}

export class Jwt {
public static readonly COOKIE_JWT_KEY = "jwt";

value: string;

private constructor(value: string) {
Expand All @@ -36,31 +35,31 @@ export class Jwt {
}

public static extractFromCookie(): Jwt | null {
const jwtCookieRaw = Cookies.get(Jwt.COOKIE_JWT_KEY) as string | undefined;
const jwtCookieRaw = getCookie(COOKIE_JWT_KEY);
if (jwtCookieRaw === undefined) {
return null;
}
return Jwt.from(jwtCookieRaw);
}

public static eraseFromCookie() {
Cookies.remove(Jwt.COOKIE_JWT_KEY);
deleteCookie(COOKIE_JWT_KEY);
}

public static extractFromLocalStorage(): Jwt | null {
const jwtRaw = window.localStorage.getItem(Jwt.COOKIE_JWT_KEY);
const jwtRaw = window.localStorage.getItem(COOKIE_JWT_KEY);
if (jwtRaw === null) {
return null;
}
return Jwt.from(jwtRaw);
}

public static putToLocalStorage(jwtRaw: string) {
window.localStorage.setItem(Jwt.COOKIE_JWT_KEY, jwtRaw);
window.localStorage.setItem(COOKIE_JWT_KEY, jwtRaw);
}

public static eraseFromLocalStorage() {
window.localStorage.removeItem(Jwt.COOKIE_JWT_KEY);
window.localStorage.removeItem(COOKIE_JWT_KEY);
}
}

Expand Down
1 change: 1 addition & 0 deletions client/src/generated/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ api/get-instruments-by-criteria-paginated-api.ts
api/get-manufacturers-api.ts
api/get-user-profile-api.ts
api/list-favorite-api.ts
api/logout-api.ts
api/remove-favorite-api.ts
api/user-registration-api.ts
base.ts
Expand Down
1 change: 1 addition & 0 deletions client/src/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ export * from "./api/get-instruments-by-criteria-paginated-api";
export * from "./api/get-manufacturers-api";
export * from "./api/get-user-profile-api";
export * from "./api/list-favorite-api";
export * from "./api/logout-api";
export * from "./api/remove-favorite-api";
export * from "./api/user-registration-api";
171 changes: 171 additions & 0 deletions client/src/generated/api/logout-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/* tslint:disable */
/* eslint-disable */
/**
* Country
* Basic Material
*
* The version of the OpenAPI document: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import type { Configuration } from "../configuration";
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from "axios";
import globalAxios from "axios";
// Some imports not used depending on template conditions
// @ts-ignore
import {
DUMMY_BASE_URL,
assertParamExists,
setApiKeyToObject,
setBasicAuthToObject,
setBearerAuthToObject,
setOAuthToObject,
setSearchParams,
serializeDataIfNeeded,
toPathString,
createRequestFunction,
} from "../common";
// @ts-ignore
import {
BASE_PATH,
COLLECTION_FORMATS,
type RequestArgs,
BaseAPI,
RequiredError,
operationServerMap,
} from "../base";
// @ts-ignore
import type { ServerError } from "../model";
/**
* LogoutApi - axios parameter creator
* @export
*/
export const LogoutApiAxiosParamCreator = function (
configuration?: Configuration,
) {
return {
/**
* Logout Endpoint
* @summary Logout Endpoint
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
logout: async (
options: RawAxiosRequestConfig = {},
): Promise<RequestArgs> => {
const localVarPath = `/api/auth/logout`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = {
method: "POST",
...baseOptions,
...options,
};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions =
baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
};
};

/**
* LogoutApi - functional programming interface
* @export
*/
export const LogoutApiFp = function (configuration?: Configuration) {
const localVarAxiosParamCreator = LogoutApiAxiosParamCreator(configuration);
return {
/**
* Logout Endpoint
* @summary Logout Endpoint
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async logout(
options?: RawAxiosRequestConfig,
): Promise<
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<object>
> {
const localVarAxiosArgs = await localVarAxiosParamCreator.logout(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath =
operationServerMap["LogoutApi.logout"]?.[localVarOperationServerIndex]
?.url;
return (axios, basePath) =>
createRequestFunction(
localVarAxiosArgs,
globalAxios,
BASE_PATH,
configuration,
)(axios, localVarOperationServerBasePath || basePath);
},
};
};

/**
* LogoutApi - factory interface
* @export
*/
export const LogoutApiFactory = function (
configuration?: Configuration,
basePath?: string,
axios?: AxiosInstance,
) {
const localVarFp = LogoutApiFp(configuration);
return {
/**
* Logout Endpoint
* @summary Logout Endpoint
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
logout(options?: RawAxiosRequestConfig): AxiosPromise<object> {
return localVarFp
.logout(options)
.then((request) => request(axios, basePath));
},
};
};

/**
* LogoutApi - object-oriented interface
* @export
* @class LogoutApi
* @extends {BaseAPI}
*/
export class LogoutApi extends BaseAPI {
/**
* Logout Endpoint
* @summary Logout Endpoint
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof LogoutApi
*/
public logout(options?: RawAxiosRequestConfig) {
return LogoutApiFp(this.configuration)
.logout(options)
.then((request) => request(this.axios, this.basePath));
}
}
85 changes: 85 additions & 0 deletions client/src/generated/model/instrument-detail-without-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* tslint:disable */
/* eslint-disable */
/**
* Country
* Basic Material
*
* The version of the OpenAPI document: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

// May contain unused imports in some cases
// @ts-ignore
import type { BasicMaterial } from "./basic-material";
// May contain unused imports in some cases
// @ts-ignore
import type { Country } from "./country";
// May contain unused imports in some cases
// @ts-ignore
import type { InstrumentName } from "./instrument-name";
// May contain unused imports in some cases
// @ts-ignore
import type { InstrumentType } from "./instrument-type";
// May contain unused imports in some cases
// @ts-ignore
import type { ManufactureDate } from "./manufacture-date";
// May contain unused imports in some cases
// @ts-ignore
import type { ManufacturerName } from "./manufacturer-name";
// May contain unused imports in some cases
// @ts-ignore
import type { ReleaseDate } from "./release-date";

/**
*
* @export
* @interface InstrumentDetailWithoutId
*/
export interface InstrumentDetailWithoutId {
/**
*
* @type {InstrumentName}
* @memberof InstrumentDetailWithoutId
*/
instrument_name: InstrumentName;
/**
*
* @type {InstrumentType}
* @memberof InstrumentDetailWithoutId
*/
instrument_type: InstrumentType;
/**
*
* @type {ManufacturerName}
* @memberof InstrumentDetailWithoutId
*/
manufacturer_name: ManufacturerName;
/**
*
* @type {ManufactureDate}
* @memberof InstrumentDetailWithoutId
*/
manufacturer_date: ManufactureDate;
/**
*
* @type {ReleaseDate}
* @memberof InstrumentDetailWithoutId
*/
release_date: ReleaseDate;
/**
*
* @type {Country}
* @memberof InstrumentDetailWithoutId
*/
country: Country;
/**
*
* @type {Array<BasicMaterial>}
* @memberof InstrumentDetailWithoutId
*/
basic_materials: Array<BasicMaterial>;
}
27 changes: 27 additions & 0 deletions client/src/generated/model/instrument-photo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* tslint:disable */
/* eslint-disable */
/**
* Country
* Basic Material
*
* The version of the OpenAPI document: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

/**
*
* @export
* @interface InstrumentPhoto
*/
export interface InstrumentPhoto {
/**
*
* @type {string}
* @memberof InstrumentPhoto
*/
photo: string;
}
Loading

0 comments on commit 04f3357

Please sign in to comment.