removed icon server and finished profile page

This commit is contained in:
Maieul BOYER 2025-12-10 17:06:53 +01:00 committed by apetitco
parent 23baa4af56
commit a8fa9f984d
26 changed files with 881 additions and 325 deletions

View file

@ -4,11 +4,15 @@ index.ts
models/ChangeDisplayName200Response.ts
models/ChangeDisplayName400Response.ts
models/ChangeDisplayNameRequest.ts
models/ChangePassword200Response.ts
models/ChangePassword400Response.ts
models/ChangePassword401Response.ts
models/ChangePassword500Response.ts
models/ChangePasswordRequest.ts
models/ChatTest200Response.ts
models/ChatTest200ResponsePayload.ts
models/DisableOtp200Response.ts
models/DisableOtp400Response.ts
models/DisableOtp401Response.ts
models/DisableOtp500Response.ts
models/EnableOtp200Response.ts
models/EnableOtp200ResponsePayload.ts

View file

@ -18,10 +18,14 @@ import type {
ChangeDisplayName200Response,
ChangeDisplayName400Response,
ChangeDisplayNameRequest,
ChangePassword200Response,
ChangePassword400Response,
ChangePassword401Response,
ChangePassword500Response,
ChangePasswordRequest,
ChatTest200Response,
DisableOtp200Response,
DisableOtp400Response,
DisableOtp401Response,
DisableOtp500Response,
EnableOtp200Response,
EnableOtp400Response,
@ -60,14 +64,22 @@ import {
ChangeDisplayName400ResponseToJSON,
ChangeDisplayNameRequestFromJSON,
ChangeDisplayNameRequestToJSON,
ChangePassword200ResponseFromJSON,
ChangePassword200ResponseToJSON,
ChangePassword400ResponseFromJSON,
ChangePassword400ResponseToJSON,
ChangePassword401ResponseFromJSON,
ChangePassword401ResponseToJSON,
ChangePassword500ResponseFromJSON,
ChangePassword500ResponseToJSON,
ChangePasswordRequestFromJSON,
ChangePasswordRequestToJSON,
ChatTest200ResponseFromJSON,
ChatTest200ResponseToJSON,
DisableOtp200ResponseFromJSON,
DisableOtp200ResponseToJSON,
DisableOtp400ResponseFromJSON,
DisableOtp400ResponseToJSON,
DisableOtp401ResponseFromJSON,
DisableOtp401ResponseToJSON,
DisableOtp500ResponseFromJSON,
DisableOtp500ResponseToJSON,
EnableOtp200ResponseFromJSON,
@ -134,6 +146,10 @@ export interface ChangeDisplayNameOperationRequest {
changeDisplayNameRequest: ChangeDisplayNameRequest;
}
export interface ChangePasswordOperationRequest {
changePasswordRequest: ChangePasswordRequest;
}
export interface GetUserRequest {
user: GetUserUserParameter;
}
@ -161,7 +177,7 @@ export class OpenapiOtherApi extends runtime.BaseAPI {
/**
*/
async changeDisplayNameRaw(requestParameters: ChangeDisplayNameOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ChangeDisplayName200Response | ChangeDisplayName400Response | DisableOtp401Response>> {
async changeDisplayNameRaw(requestParameters: ChangeDisplayNameOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ChangeDisplayName200Response | ChangeDisplayName400Response | ChangePassword401Response>> {
if (requestParameters['changeDisplayNameRequest'] == null) {
throw new runtime.RequiredError(
'changeDisplayNameRequest',
@ -200,7 +216,7 @@ export class OpenapiOtherApi extends runtime.BaseAPI {
}
if (response.status === 401) {
// Object response for status 401
return new runtime.JSONApiResponse(response, (jsonValue) => DisableOtp401ResponseFromJSON(jsonValue));
return new runtime.JSONApiResponse(response, (jsonValue) => ChangePassword401ResponseFromJSON(jsonValue));
}
// CHANGED: Throw error if status code is not handled by any of the defined responses
// This ensures all code paths return a value and provides clear error messages for unexpected status codes
@ -210,11 +226,71 @@ export class OpenapiOtherApi extends runtime.BaseAPI {
/**
*/
async changeDisplayName(requestParameters: ChangeDisplayNameOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ChangeDisplayName200Response | ChangeDisplayName400Response | DisableOtp401Response> {
async changeDisplayName(requestParameters: ChangeDisplayNameOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ChangeDisplayName200Response | ChangeDisplayName400Response | ChangePassword401Response> {
const response = await this.changeDisplayNameRaw(requestParameters, initOverrides);
return await response.value();
}
/**
*/
async changePasswordRaw(requestParameters: ChangePasswordOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ChangePassword200Response | ChangePassword400Response | ChangePassword401Response | ChangePassword500Response>> {
if (requestParameters['changePasswordRequest'] == null) {
throw new runtime.RequiredError(
'changePasswordRequest',
'Required parameter "changePasswordRequest" was null or undefined when calling changePassword().'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
let urlPath = `/api/auth/changePassword`;
const response = await this.request({
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: ChangePasswordRequestToJSON(requestParameters['changePasswordRequest']),
}, initOverrides);
// CHANGED: Handle all status codes defined in the OpenAPI spec, not just 2xx responses
// This allows typed access to error responses (4xx, 5xx) and other status codes.
// The code routes responses based on the actual HTTP status code and returns
// appropriately typed ApiResponse wrappers for each status code.
if (response.status === 200) {
// Object response for status 200
return new runtime.JSONApiResponse(response, (jsonValue) => ChangePassword200ResponseFromJSON(jsonValue));
}
if (response.status === 400) {
// Object response for status 400
return new runtime.JSONApiResponse(response, (jsonValue) => ChangePassword400ResponseFromJSON(jsonValue));
}
if (response.status === 401) {
// Object response for status 401
return new runtime.JSONApiResponse(response, (jsonValue) => ChangePassword401ResponseFromJSON(jsonValue));
}
if (response.status === 500) {
// Object response for status 500
return new runtime.JSONApiResponse(response, (jsonValue) => ChangePassword500ResponseFromJSON(jsonValue));
}
// CHANGED: Throw error if status code is not handled by any of the defined responses
// This ensures all code paths return a value and provides clear error messages for unexpected status codes
// Only throw if responses were defined but none matched the actual status code
throw new runtime.ResponseError(response, `Unexpected status code: ${response.status}. Expected one of: 200, 400, 401, 500`);
}
/**
*/
async changePassword(requestParameters: ChangePasswordOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ChangePassword200Response | ChangePassword400Response | ChangePassword401Response | ChangePassword500Response> {
const response = await this.changePasswordRaw(requestParameters, initOverrides);
return await response.value();
}
/**
*/
async chatTestRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ChatTest200Response | StatusOtp401Response>> {
@ -259,7 +335,7 @@ export class OpenapiOtherApi extends runtime.BaseAPI {
/**
*/
async disableOtpRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<DisableOtp200Response | DisableOtp400Response | DisableOtp401Response | DisableOtp500Response>> {
async disableOtpRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<DisableOtp200Response | DisableOtp400Response | ChangePassword401Response | DisableOtp500Response>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
@ -288,7 +364,7 @@ export class OpenapiOtherApi extends runtime.BaseAPI {
}
if (response.status === 401) {
// Object response for status 401
return new runtime.JSONApiResponse(response, (jsonValue) => DisableOtp401ResponseFromJSON(jsonValue));
return new runtime.JSONApiResponse(response, (jsonValue) => ChangePassword401ResponseFromJSON(jsonValue));
}
if (response.status === 500) {
// Object response for status 500
@ -302,7 +378,7 @@ export class OpenapiOtherApi extends runtime.BaseAPI {
/**
*/
async disableOtp(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DisableOtp200Response | DisableOtp400Response | DisableOtp401Response | DisableOtp500Response> {
async disableOtp(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DisableOtp200Response | DisableOtp400Response | ChangePassword401Response | DisableOtp500Response> {
const response = await this.disableOtpRaw(initOverrides);
return await response.value();
}

View file

@ -0,0 +1,93 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface ChangePassword200Response
*/
export interface ChangePassword200Response {
/**
*
* @type {string}
* @memberof ChangePassword200Response
*/
kind: ChangePassword200ResponseKindEnum;
/**
*
* @type {string}
* @memberof ChangePassword200Response
*/
msg: ChangePassword200ResponseMsgEnum;
}
/**
* @export
*/
export const ChangePassword200ResponseKindEnum = {
Success: 'success'
} as const;
export type ChangePassword200ResponseKindEnum = typeof ChangePassword200ResponseKindEnum[keyof typeof ChangePassword200ResponseKindEnum];
/**
* @export
*/
export const ChangePassword200ResponseMsgEnum = {
ChangePasswordSuccess: 'changePassword.success'
} as const;
export type ChangePassword200ResponseMsgEnum = typeof ChangePassword200ResponseMsgEnum[keyof typeof ChangePassword200ResponseMsgEnum];
/**
* Check if a given object implements the ChangePassword200Response interface.
*/
export function instanceOfChangePassword200Response(value: object): value is ChangePassword200Response {
if (!('kind' in value) || value['kind'] === undefined) return false;
if (!('msg' in value) || value['msg'] === undefined) return false;
return true;
}
export function ChangePassword200ResponseFromJSON(json: any): ChangePassword200Response {
return ChangePassword200ResponseFromJSONTyped(json, false);
}
export function ChangePassword200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ChangePassword200Response {
if (json == null) {
return json;
}
return {
'kind': json['kind'],
'msg': json['msg'],
};
}
export function ChangePassword200ResponseToJSON(json: any): ChangePassword200Response {
return ChangePassword200ResponseToJSONTyped(json, false);
}
export function ChangePassword200ResponseToJSONTyped(value?: ChangePassword200Response | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'kind': value['kind'],
'msg': value['msg'],
};
}

View file

@ -0,0 +1,95 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface ChangePassword400Response
*/
export interface ChangePassword400Response {
/**
*
* @type {string}
* @memberof ChangePassword400Response
*/
kind: ChangePassword400ResponseKindEnum;
/**
*
* @type {string}
* @memberof ChangePassword400Response
*/
msg: ChangePassword400ResponseMsgEnum;
}
/**
* @export
*/
export const ChangePassword400ResponseKindEnum = {
Failed: 'failed'
} as const;
export type ChangePassword400ResponseKindEnum = typeof ChangePassword400ResponseKindEnum[keyof typeof ChangePassword400ResponseKindEnum];
/**
* @export
*/
export const ChangePassword400ResponseMsgEnum = {
ChangePasswordFailedToolong: 'changePassword.failed.toolong',
ChangePasswordFailedTooshort: 'changePassword.failed.tooshort',
ChangePasswordFailedInvalid: 'changePassword.failed.invalid'
} as const;
export type ChangePassword400ResponseMsgEnum = typeof ChangePassword400ResponseMsgEnum[keyof typeof ChangePassword400ResponseMsgEnum];
/**
* Check if a given object implements the ChangePassword400Response interface.
*/
export function instanceOfChangePassword400Response(value: object): value is ChangePassword400Response {
if (!('kind' in value) || value['kind'] === undefined) return false;
if (!('msg' in value) || value['msg'] === undefined) return false;
return true;
}
export function ChangePassword400ResponseFromJSON(json: any): ChangePassword400Response {
return ChangePassword400ResponseFromJSONTyped(json, false);
}
export function ChangePassword400ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ChangePassword400Response {
if (json == null) {
return json;
}
return {
'kind': json['kind'],
'msg': json['msg'],
};
}
export function ChangePassword400ResponseToJSON(json: any): ChangePassword400Response {
return ChangePassword400ResponseToJSONTyped(json, false);
}
export function ChangePassword400ResponseToJSONTyped(value?: ChangePassword400Response | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'kind': value['kind'],
'msg': value['msg'],
};
}

View file

@ -0,0 +1,96 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface ChangePassword401Response
*/
export interface ChangePassword401Response {
/**
*
* @type {string}
* @memberof ChangePassword401Response
*/
kind: ChangePassword401ResponseKindEnum;
/**
*
* @type {string}
* @memberof ChangePassword401Response
*/
msg: ChangePassword401ResponseMsgEnum;
}
/**
* @export
*/
export const ChangePassword401ResponseKindEnum = {
NotLoggedIn: 'notLoggedIn'
} as const;
export type ChangePassword401ResponseKindEnum = typeof ChangePassword401ResponseKindEnum[keyof typeof ChangePassword401ResponseKindEnum];
/**
* @export
*/
export const ChangePassword401ResponseMsgEnum = {
AuthNoCookie: 'auth.noCookie',
AuthInvalidKind: 'auth.invalidKind',
AuthNoUser: 'auth.noUser',
AuthInvalid: 'auth.invalid'
} as const;
export type ChangePassword401ResponseMsgEnum = typeof ChangePassword401ResponseMsgEnum[keyof typeof ChangePassword401ResponseMsgEnum];
/**
* Check if a given object implements the ChangePassword401Response interface.
*/
export function instanceOfChangePassword401Response(value: object): value is ChangePassword401Response {
if (!('kind' in value) || value['kind'] === undefined) return false;
if (!('msg' in value) || value['msg'] === undefined) return false;
return true;
}
export function ChangePassword401ResponseFromJSON(json: any): ChangePassword401Response {
return ChangePassword401ResponseFromJSONTyped(json, false);
}
export function ChangePassword401ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ChangePassword401Response {
if (json == null) {
return json;
}
return {
'kind': json['kind'],
'msg': json['msg'],
};
}
export function ChangePassword401ResponseToJSON(json: any): ChangePassword401Response {
return ChangePassword401ResponseToJSONTyped(json, false);
}
export function ChangePassword401ResponseToJSONTyped(value?: ChangePassword401Response | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'kind': value['kind'],
'msg': value['msg'],
};
}

View file

@ -0,0 +1,93 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface ChangePassword500Response
*/
export interface ChangePassword500Response {
/**
*
* @type {string}
* @memberof ChangePassword500Response
*/
kind: ChangePassword500ResponseKindEnum;
/**
*
* @type {string}
* @memberof ChangePassword500Response
*/
msg: ChangePassword500ResponseMsgEnum;
}
/**
* @export
*/
export const ChangePassword500ResponseKindEnum = {
Failed: 'failed'
} as const;
export type ChangePassword500ResponseKindEnum = typeof ChangePassword500ResponseKindEnum[keyof typeof ChangePassword500ResponseKindEnum];
/**
* @export
*/
export const ChangePassword500ResponseMsgEnum = {
ChangePasswordFailedGeneric: 'changePassword.failed.generic'
} as const;
export type ChangePassword500ResponseMsgEnum = typeof ChangePassword500ResponseMsgEnum[keyof typeof ChangePassword500ResponseMsgEnum];
/**
* Check if a given object implements the ChangePassword500Response interface.
*/
export function instanceOfChangePassword500Response(value: object): value is ChangePassword500Response {
if (!('kind' in value) || value['kind'] === undefined) return false;
if (!('msg' in value) || value['msg'] === undefined) return false;
return true;
}
export function ChangePassword500ResponseFromJSON(json: any): ChangePassword500Response {
return ChangePassword500ResponseFromJSONTyped(json, false);
}
export function ChangePassword500ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ChangePassword500Response {
if (json == null) {
return json;
}
return {
'kind': json['kind'],
'msg': json['msg'],
};
}
export function ChangePassword500ResponseToJSON(json: any): ChangePassword500Response {
return ChangePassword500ResponseToJSONTyped(json, false);
}
export function ChangePassword500ResponseToJSONTyped(value?: ChangePassword500Response | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'kind': value['kind'],
'msg': value['msg'],
};
}

View file

@ -0,0 +1,66 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface ChangePasswordRequest
*/
export interface ChangePasswordRequest {
/**
*
* @type {string}
* @memberof ChangePasswordRequest
*/
newPassword: string;
}
/**
* Check if a given object implements the ChangePasswordRequest interface.
*/
export function instanceOfChangePasswordRequest(value: object): value is ChangePasswordRequest {
if (!('newPassword' in value) || value['newPassword'] === undefined) return false;
return true;
}
export function ChangePasswordRequestFromJSON(json: any): ChangePasswordRequest {
return ChangePasswordRequestFromJSONTyped(json, false);
}
export function ChangePasswordRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): ChangePasswordRequest {
if (json == null) {
return json;
}
return {
'newPassword': json['new_password'],
};
}
export function ChangePasswordRequestToJSON(json: any): ChangePasswordRequest {
return ChangePasswordRequestToJSONTyped(json, false);
}
export function ChangePasswordRequestToJSONTyped(value?: ChangePasswordRequest | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'new_password': value['newPassword'],
};
}

View file

@ -13,13 +13,6 @@
*/
import { mapValues } from '../runtime';
import type { DisableOtp401Response } from './DisableOtp401Response';
import {
DisableOtp401ResponseFromJSON,
DisableOtp401ResponseFromJSONTyped,
DisableOtp401ResponseToJSON,
DisableOtp401ResponseToJSONTyped,
} from './DisableOtp401Response';
import type { EnableOtp401ResponseAnyOf } from './EnableOtp401ResponseAnyOf';
import {
EnableOtp401ResponseAnyOfFromJSON,
@ -27,6 +20,13 @@ import {
EnableOtp401ResponseAnyOfToJSON,
EnableOtp401ResponseAnyOfToJSONTyped,
} from './EnableOtp401ResponseAnyOf';
import type { ChangePassword401Response } from './ChangePassword401Response';
import {
ChangePassword401ResponseFromJSON,
ChangePassword401ResponseFromJSONTyped,
ChangePassword401ResponseToJSON,
ChangePassword401ResponseToJSONTyped,
} from './ChangePassword401Response';
/**
*

View file

@ -13,13 +13,13 @@
*/
import { mapValues } from '../runtime';
import type { DisableOtp401Response } from './DisableOtp401Response';
import type { ChangePassword401Response } from './ChangePassword401Response';
import {
DisableOtp401ResponseFromJSON,
DisableOtp401ResponseFromJSONTyped,
DisableOtp401ResponseToJSON,
DisableOtp401ResponseToJSONTyped,
} from './DisableOtp401Response';
ChangePassword401ResponseFromJSON,
ChangePassword401ResponseFromJSONTyped,
ChangePassword401ResponseToJSON,
ChangePassword401ResponseToJSONTyped,
} from './ChangePassword401Response';
/**
*

View file

@ -3,11 +3,15 @@
export * from './ChangeDisplayName200Response';
export * from './ChangeDisplayName400Response';
export * from './ChangeDisplayNameRequest';
export * from './ChangePassword200Response';
export * from './ChangePassword400Response';
export * from './ChangePassword401Response';
export * from './ChangePassword500Response';
export * from './ChangePasswordRequest';
export * from './ChatTest200Response';
export * from './ChatTest200ResponsePayload';
export * from './DisableOtp200Response';
export * from './DisableOtp400Response';
export * from './DisableOtp401Response';
export * from './DisableOtp500Response';
export * from './EnableOtp200Response';
export * from './EnableOtp200ResponsePayload';

View file

@ -1,4 +1,4 @@
import { addRoute, handleRoute, navigateTo, setTitle } from "@app/routing";
import { addRoute, getRoute, handleRoute, navigateTo, setTitle } from "@app/routing";
import { showError, showSuccess } from "@app/toast";
import page from "./profile.html?raw";
import { updateUser } from "@app/auth";
@ -159,7 +159,7 @@ async function route(url: string, _args: { [k: string]: string }) {
} else if (!isNullish(user.selfInfo?.loginName)) {
loginNameWrapper.hidden = false;
loginNameBox.innerText = user.selfInfo.loginName;
totpWrapper.hidden =false;
totpWrapper.hidden = false;
passwordWrapper.hidden = false;
accountTypeBox.innerText = "Normal";
@ -244,6 +244,19 @@ async function route(url: string, _args: { [k: string]: string }) {
showError(`Failed to update: ${req.msg}`);
}
};
passwordButton.onclick = async () => {
let req = await client.changePassword({
changePasswordRequest: {
newPassword: passwordBox.value,
},
});
if (req.kind === "success") {
showSuccess("Successfully changed password");
handleRoute();
} else {
showError(`Failed to update: ${req.msg}`);
}
};
// Initialize UI state
refreshTotpUI();