question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to let user edit profile?

See original GitHub issue

Core Library

@azure/msal-browser

Core Library Version

2.14.0

Wrapper Library

@azure/msal-angular

Wrapper Library Version

2.0.0-beta.4

Description

I’m trying to let user edit their profile in my application, but the only function that takes the user to edit profile page is the “loginRedirect” or “loginPopup”. The problem is that, when I use that functions and the user complete the flow, the msal library gets two accounts on “getAllAccounts()” and none of them has the updated info.

MSAL Configuration

{ auth: { clientId: ‘', authority: '’, navigateToLoginRequestUrl: false, redirectUri: ${window.location.origin}, }, cache: { cacheLocation: ‘localStorage’, } }

Relevant Code Snippets

const client = new PublicClientApplication({ auth: { clientId: ‘', authority: '’, navigateToLoginRequestUrl: false, redirectUri: ${window.location.origin}, }, cache: { cacheLocation: ‘localStorage’, } })

client.loginRedirect()

Identity Provider

Azure B2C Custom Policy

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tnorlingcommented, May 25, 2021

@luismiguelprs @tiny-dancer Right now the way the B2C service is designed (separating different operations into different user flows) causes MSAL to see idTokens from different flows as completely different “users” (tokens are also not shared across flows). If and until that design changes there are 2 approaches you can take to work around the multiple account issue:

  1. Filter the result of getAllAccounts and choose the account for the flow you wish to use. You can find the name of the flow the account belongs to in either idTokenClaims.tfp or idTokenClaims.acr on each account object.
  2. When you receive a response from the edit profile flow immediately call logout with the account that was returned in the response. (This approach is demonstrated in the angular b2c sample here)
1reaction
hectormmgcommented, May 7, 2021

@luismiguelprs I think I understand now.

Given that MSAL has to support multiple authentication services, there aren’t any B2C specific APIs (such as ClientApplication.editProfileRedirect()). Using the login and acquireToken APIs for these use cases is the right approach. As to the duplicate accounts after a user changes their profile information, we’ll take a look and see if we can reproduce the behavior and see if there’s changes to be made to fix this. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allowing user to edit their profile - Microsoft Community Hub
Hi, Is there any way to allow user to edit their own profile information such as Names, Job title...etc. Or
Read more >
Allow Directory users to change their profile and photo
Allow or disallow users to edit their profile · Sign in to your Google Admin console. · In the Admin console, go to...
Read more >
How can I allow users to edit their profiles in Django?
1. Create a UserEditForm. in forms.py from .models import UserProfile from django. · 2. Create a View: in views.py from django.shortcuts import ...
Read more >
How to edit a user's profile page & fill out empty fields
If users did not fill out all the fields in their profile, an admin or editor can edit the user's profile and complete...
Read more >
How to Edit a WordPress User Profile on the Front End
Only members will need to edit their profile details. So, it's best to limit the Edit User Profile form to logged-in users only....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found