add a check to each auth context to mark if it supports persisting the login

This commit is contained in:
Jacob Overgaard
2023-05-30 10:17:44 +02:00
parent 96f2020433
commit 62e522fae2
4 changed files with 8 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import { LoginRequestModel, IUmbAuthContext, LoginResponse } from './types.js';
export class UmbAuthLegacyContext implements IUmbAuthContext {
readonly #AUTH_URL = '/umbraco/backoffice/umbracoapi/authentication/postlogin';
readonly supportsPersistLogin = true;
login(data: LoginRequestModel): Promise<LoginResponse> {
throw new Error('Method not implemented.');

View File

@@ -3,6 +3,7 @@ import { LoginRequestModel, IUmbAuthContext } from './types.js';
export class UmbAuthContext implements IUmbAuthContext {
readonly #AUTH_URL = '/umbraco/management/api/v1/security/back-office';
readonly supportsPersistLogin = false;
#authRepository = new UmbAuthRepository(this.#AUTH_URL);

View File

@@ -105,9 +105,11 @@ export default class UmbLoginElement extends LitElement {
required-message="Password is required"></uui-input-password>
</uui-form-layout-item>
<uui-form-layout-item>
<uui-checkbox name="persist" label="Remember me">Remember me</uui-checkbox>
</uui-form-layout-item>
${this.#authContext.supportsPersistLogin
? html`<uui-form-layout-item>
<uui-checkbox name="persist" label="Remember me">Remember me</uui-checkbox>
</uui-form-layout-item>`
: nothing}
<uui-form-layout-item>${this.#renderErrorMessage()}</uui-form-layout-item>

View File

@@ -6,6 +6,7 @@ export type LoginRequestModel = {
export interface IUmbAuthContext {
login(data: LoginRequestModel): Promise<LoginResponse>;
supportsPersistLogin: boolean;
}
export type LoginResponse = {