From aa0f656ed8ef74dc9ef0020b32a6237d4a07a300 Mon Sep 17 00:00:00 2001 From: henridb <henridb@stud.ntnu.no> Date: Mon, 22 Apr 2024 23:19:43 +0200 Subject: [PATCH] feat: add reset password endpoints --- src/api/index.ts | 3 +- ...serControllerService.ts => UserService.ts} | 52 ++++++++++++++++--- 2 files changed, 48 insertions(+), 7 deletions(-) rename src/api/services/{UserControllerService.ts => UserService.ts} (53%) diff --git a/src/api/index.ts b/src/api/index.ts index 22e1808..952a64c 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -12,6 +12,7 @@ export type { ExceptionResponse } from './models/ExceptionResponse'; export type { LeaderboardDTO } from './models/LeaderboardDTO'; export type { LeaderboardEntryDTO } from './models/LeaderboardEntryDTO'; export type { LoginRequest } from './models/LoginRequest'; +export type { PasswordResetDTO } from './models/PasswordResetDTO'; export type { ProfileDTO } from './models/ProfileDTO'; export type { SignUpRequest } from './models/SignUpRequest'; export type { UserDTO } from './models/UserDTO'; @@ -19,4 +20,4 @@ export type { UserUpdateDTO } from './models/UserUpdateDTO'; export { AuthenticationService } from './services/AuthenticationService'; export { LeaderboardService } from './services/LeaderboardService'; -export { UserControllerService } from './services/UserControllerService'; +export { UserService } from './services/UserService'; diff --git a/src/api/services/UserControllerService.ts b/src/api/services/UserService.ts similarity index 53% rename from src/api/services/UserControllerService.ts rename to src/api/services/UserService.ts index 5a1ea35..d4bec02 100644 --- a/src/api/services/UserControllerService.ts +++ b/src/api/services/UserService.ts @@ -2,15 +2,55 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { PasswordResetDTO } from '../models/PasswordResetDTO'; import type { ProfileDTO } from '../models/ProfileDTO'; import type { UserDTO } from '../models/UserDTO'; import type { UserUpdateDTO } from '../models/UserUpdateDTO'; import type { CancelablePromise } from '../core/CancelablePromise'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; -export class UserControllerService { +export class UserService { /** - * Update profile + * Initiate a password reset + * Send a password reset mail to the user with the specified email + * @returns any Successfully initiated a password reset + * @throws ApiError + */ + public static resetPassword({ + requestBody, + }: { + requestBody: string, + }): CancelablePromise<any> { + return __request(OpenAPI, { + method: 'POST', + url: '/api/users/reset-password', + body: requestBody, + mediaType: 'text/plain', + }); + } + /** + * Confirm a password reset + * Confirms a password reset using a token and a new password + * @returns void + * @throws ApiError + */ + public static confirmPasswordReset({ + requestBody, + }: { + requestBody: PasswordResetDTO, + }): CancelablePromise<void> { + return __request(OpenAPI, { + method: 'POST', + url: '/api/users/confirm-password', + body: requestBody, + mediaType: 'application/json', + errors: { + 403: `Invalid token`, + }, + }); + } + /** + * Update a profile * Update the profile of the authenticated user * @returns UserDTO Successfully updated profile * @throws ApiError @@ -28,8 +68,8 @@ export class UserControllerService { }); } /** - * Get profile - * Get user profile + * Get a profile + * Get the profile of a user * @returns ProfileDTO Successfully got profile * @throws ApiError */ @@ -47,8 +87,8 @@ export class UserControllerService { }); } /** - * Get user - * Get user information + * Get the authenticated user + * Get all user information for the authenticated user * @returns UserDTO Successfully got user * @throws ApiError */ -- GitLab