mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-24 06:28:34 +01:00
move to nuxt
This commit is contained in:
34
frontend/lib/api/user.ts
Normal file
34
frontend/lib/api/user.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Requests } from "~~/lib/requests";
|
||||
import { BaseAPI, UrlBuilder } from "./base";
|
||||
import { LocationsApi } from "./classes/locations";
|
||||
|
||||
export type Result<T> = {
|
||||
item: T;
|
||||
};
|
||||
|
||||
export type User = {
|
||||
name: string;
|
||||
email: string;
|
||||
isSuperuser: boolean;
|
||||
id: number;
|
||||
};
|
||||
|
||||
export class UserApi extends BaseAPI {
|
||||
locations: LocationsApi;
|
||||
|
||||
constructor(requests: Requests) {
|
||||
super(requests);
|
||||
|
||||
this.locations = new LocationsApi(requests);
|
||||
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
public self() {
|
||||
return this.http.get<Result<User>>(UrlBuilder("/users/self"));
|
||||
}
|
||||
|
||||
public logout() {
|
||||
return this.http.post<object, void>(UrlBuilder("/users/logout"), {});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user