forked from mirrors/homebox
fix: cookie-auth-issues (#365)
* fix session clearing on error * use singleton context to manage user state * implement remember-me functionality * fix errors * fix more errors
This commit is contained in:
parent
ed1230e17d
commit
faed343eda
24 changed files with 175 additions and 89 deletions
|
@ -1,10 +1,5 @@
|
|||
import { BaseAPI, route } from "./base";
|
||||
import { ApiSummary, TokenResponse, UserRegistration } from "./types/data-contracts";
|
||||
|
||||
export type LoginPayload = {
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
import { ApiSummary, LoginForm, TokenResponse, UserRegistration } from "./types/data-contracts";
|
||||
|
||||
export type StatusResult = {
|
||||
health: boolean;
|
||||
|
@ -18,12 +13,13 @@ export class PublicApi extends BaseAPI {
|
|||
return this.http.get<ApiSummary>({ url: route("/status") });
|
||||
}
|
||||
|
||||
public login(username: string, password: string) {
|
||||
return this.http.post<LoginPayload, TokenResponse>({
|
||||
public login(username: string, password: string, stayLoggedIn = false) {
|
||||
return this.http.post<LoginForm, TokenResponse>({
|
||||
url: route("/users/login"),
|
||||
body: {
|
||||
username,
|
||||
password,
|
||||
stayLoggedIn,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -412,6 +412,12 @@ export interface ItemAttachmentToken {
|
|||
token: string;
|
||||
}
|
||||
|
||||
export interface LoginForm {
|
||||
password: string;
|
||||
stayLoggedIn: boolean;
|
||||
username: string;
|
||||
}
|
||||
|
||||
export interface TokenResponse {
|
||||
attachmentToken: string;
|
||||
expiresAt: Date | string;
|
||||
|
|
|
@ -39,19 +39,4 @@ export class UserClient extends BaseAPI {
|
|||
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
/** @deprecated use this.user.self() */
|
||||
public self() {
|
||||
return this.user.self();
|
||||
}
|
||||
|
||||
/** @deprecated use this.user.logout() */
|
||||
public logout() {
|
||||
return this.user.logout();
|
||||
}
|
||||
|
||||
/** @deprecated use this.user.delete() */
|
||||
public deleteAccount() {
|
||||
return this.user.delete();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue