score:2
what i did was create a route in my app.js:
<route
path="/forgot"
component={() => {
window.location.href = forgotpasswordurl;
return null;
}}
/>
then, in the constructor
if (window.location.hash.indexof('aadb2c90118') >= 0) {
history.push('/forgot');
}
and that works.
score:0
using msal-react
and msal-browser
i was able to get the azure ad b2c password reset page to appear using the following code (assuming you created a password reset user flow named b2c_1_reset
):
import { usemsal } from "@azure/msal-react";
import { eventtype } from '@azure/msal-browser';
....
const { instance, inprogress, accounts } = usemsal();
// msal logging
//instance.setlogger(new logger(loggercallback));
const callbackid = instance.addeventcallback((message) => {
if (message.eventtype === eventtype.login_failure){
if (message.error.errormessage.includes("aadb2c90118")) { // the user has forgotten their password.
const authority = "https://<your_domain>.b2clogin.com/crowdalert.onmicrosoft.com/b2c_1_reset";
instance.loginredirect({authority: authority})
}
}
});
score:0
credit to ian for the hint.
you should add an extra condition in case the user cancels their attempt to change reset their account credentials. this way they are redirected back to login instead of getting stuck on your app.
import { usemsal } from "@azure/msal-react";
export default mycomponent = () => {
// other code
const { instance, accounts, inprogress } = usemsal();
instance.addeventcallback((message: any) => {
if (message.eventtype === eventtype.login_failure && message.error.errormessage.includes("aadb2c90118")) {
// the user has forgotten their password.
instance.loginredirect(passwordresetrequest);
} else if (message.eventtype === eventtype.handle_redirect_end && inprogress === interactionstatus.none) {
instance.loginredirect(loginrequest);
}
});
// rest of component
};
score:1
when using a combined sign-up/sign-in policy in azure b2c, users have to handle the forgot password scenario themselves. you can find more detailed comments here.
a sign-up or sign-in user flow with local accounts includes a "forgot password?" link on the first page of the experience. clicking this link doesn't automatically trigger a password reset user flow.
instead, the error code aadb2c90118 is returned to your application. your application needs to handle this error code by running a specific user flow that resets the password. to see an example, take a look at a simple asp.net sample that demonstrates the linking of user flows.
Source: stackoverflow.com
Related Query
- How to integrate azure b2c with react
- How do I make 'forgot password' working in react-aad-msal with Azure AD B2C?
- How to make svg react component imports from external module working with create-react-app?
- How do I make ESlint less stringent while working with Prettier in a React project (with Material-UI)?
- How to make CSS grid working in react with CSS modules stylesheet
- How make my login function working with React functional components using React-Router (TypeScript)?
- How to make react router work with static assets, html5 mode, history API and nested routes?
- How to make a Bootstrap dropdown with React
- How can I make React Portal work with React Hook?
- React PropTypes - How to make a shape optional with its fields required?
- React Native: How to make format card expiration with / using <TextInput/>?
- How to make pure, generic React components with immutable data that needs to be transformed
- How to make a Semantic UI React grid full screen with different row heights?
- How to use Turborepo for an existing react app created with Create React App in order to make it a monorepo?
- how to make google bots crawl my react website with dynamic urls and display them in google
- How can I make my React app render Bootstrap tables with crud
- Ionic popover with React - How to make it sticky to the button
- How to make a gradient background in React with single color?
- How to make VSCode play nice with React syntax?
- How to make vertical tabs with React
- Djanog with React how to reset user password by sending user an email
- How to make AJAX GET request on the client to external site with React
- How to make registration mandatory with Firebase auth in my React app?
- How do I make my react app still run with lint errors?
- How to fix "TypeError: items.map is not a function" when working with React and APIs?
- How to make react semantic UI TextArea with default value, but still allows user to change the value?
- How to make a React multi-step form work with React Router?
- In React with Redux how to make double colons work
- How to make a react component with Async data re-usable in Redux flow?
- How to make a functional React component with generic type?
More Query from same tag
- Webpack dynamic import .json file?
- React: Render other blocks
- Lost input focus when trying to update an array of objects in React Hooks
- How to set selection at "holding" state in Javascript?
- How to create a Component on Click React
- Infogram embed code not rendering in React
- Reactjs Material: How to pass to props to reactjs material dialog
- how do i get styled-components to work with material-ui
- ReactJS Material UI inkbar not appearing for tabs
- How to get current URL domain for react for server side rendering?
- How to use @Action in Mobx + reactjs?
- how to update an object within an array during an asyncThunk.fulfilled action in Redux
- How do I use jest to test jsx components?
- React.js: How to get all props component expects?
- Why is onClick not shown in Element?
- assign displayName to react static component
- Use options to change URL in Nextjs with React-select
- React setState hook from scroll event listener
- Why can I not pass props to child component React?
- Extending Material UI's existing dark mode colors
- Access components props which is returned from HOC - Jest with React
- Why my redux state is null but in console everything is working
- Shirt.size is not updating as intended to do so
- How to open Materialize confirmation modal when deleting something from a database
- ReactJS - Props.children changed but component not re-render
- React Js - Create component from String doesn't work
- ReactJS set state of another class through props callback
- Do unfulfilled Promises cause memory leaks in React?
- Change disabled Material UI checkbox color or background color
- Child component is not getting data from the parent component