V13 RC: Fix issue with 2FA login (#15140)
* add returnPath to 2fa custom views so they know where to redirect the user to * fix(2fa): send back the user details in the login-success event emitter in case the login happens inside the backoffice overlay
This commit is contained in:
@@ -7,7 +7,8 @@ import { umbLocalizationContext } from '../../external/localization/localization
|
||||
import { loadCustomView, renderCustomView } from '../../utils/load-custom-view.function.js';
|
||||
|
||||
type MfaCustomViewElement = HTMLElement & {
|
||||
providers: string[];
|
||||
providers?: string[];
|
||||
returnPath?: string;
|
||||
};
|
||||
|
||||
@customElement('umb-mfa-page')
|
||||
@@ -107,7 +108,7 @@ export default class UmbMfaPageElement extends LitElement {
|
||||
location.href = returnPath;
|
||||
}
|
||||
|
||||
this.dispatchEvent(new CustomEvent('umb-login-success', { bubbles: true, composed: true }));
|
||||
this.dispatchEvent(new CustomEvent('umb-login-success', { bubbles: true, composed: true, detail: response.data }));
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
this.error = e.message ?? 'Unknown error';
|
||||
@@ -200,6 +201,7 @@ export default class UmbMfaPageElement extends LitElement {
|
||||
const customView = await loadCustomView<MfaCustomViewElement>(view);
|
||||
if (typeof customView === 'object') {
|
||||
customView.providers = this.providers.map((provider) => provider.value);
|
||||
customView.returnPath = umbAuthContext.returnPath;
|
||||
}
|
||||
return renderCustomView(customView);
|
||||
} catch (e) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type {
|
||||
LoginRequestModel,
|
||||
LoginResponse,
|
||||
MfaProvidersResponse,
|
||||
ResetPasswordResponse,
|
||||
ValidatePasswordResetCodeResponse,
|
||||
LoginRequestModel,
|
||||
LoginResponse,
|
||||
MfaProvidersResponse,
|
||||
ResetPasswordResponse,
|
||||
ValidatePasswordResetCodeResponse,
|
||||
} from '../types.js';
|
||||
import { umbLocalizationContext } from '../external/localization/localization-context.js';
|
||||
|
||||
@@ -215,17 +215,18 @@ export class UmbAuthRepository {
|
||||
|
||||
const response = await fetch(request);
|
||||
|
||||
let text = await response.text();
|
||||
text = this.#removeAngularJSResponseData(text);
|
||||
|
||||
const data = JSON.parse(text);
|
||||
|
||||
if (response.ok) {
|
||||
return {
|
||||
data,
|
||||
status: response.status,
|
||||
};
|
||||
}
|
||||
|
||||
let text = await response.text();
|
||||
text = this.#removeAngularJSResponseData(text);
|
||||
|
||||
const data = JSON.parse(text);
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
error: data.Message ?? 'An unknown error occurred.',
|
||||
|
||||
Reference in New Issue
Block a user