2022-10-07 02:54:09 +00:00
|
|
|
import { BaseAPI, route } from "../base";
|
2024-03-01 18:08:14 +00:00
|
|
|
import type { ChangePassword, UserOut } from "../types/data-contracts";
|
|
|
|
import type { Result } from "../types/non-generated";
|
2022-10-07 02:54:09 +00:00
|
|
|
|
|
|
|
export class UserApi extends BaseAPI {
|
|
|
|
public self() {
|
|
|
|
return this.http.get<Result<UserOut>>({ url: route("/users/self") });
|
|
|
|
}
|
|
|
|
|
|
|
|
public logout() {
|
|
|
|
return this.http.post<object, void>({ url: route("/users/logout") });
|
|
|
|
}
|
|
|
|
|
|
|
|
public delete() {
|
|
|
|
return this.http.delete<void>({ url: route("/users/self") });
|
|
|
|
}
|
2022-10-09 17:23:21 +00:00
|
|
|
|
|
|
|
public changePassword(current: string, newPassword: string) {
|
|
|
|
return this.http.put<ChangePassword, void>({
|
|
|
|
url: route("/users/self/change-password"),
|
|
|
|
body: {
|
|
|
|
current,
|
|
|
|
new: newPassword,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2022-10-07 02:54:09 +00:00
|
|
|
}
|