c# - Editing asp.net core identity claims instead of adding them -


i'm using external logins asp.net core mvc website, , when login completes want store social info used login (such username, profile image, etc.) claims in user's identity...

so run code in account controller after successful login:

    var authclaim = user.claims.firstordefault(c => c.claimtype == authtoken.name);     if (authclaim == null)           externalclaims.add(new claim(authtoken.name, authtoken.value));     else           authclaim.claimvalue = authtoken.value;      if (externalclaims.any())           await _usermanager.addclaimsasync(user, externalclaims);  await _usermanager.updateasync(user); 

however when attempt this, claims table duplicating claims rather updating them expected, every time user logs in collection of records in table user identical last.

do have delete them , re-add them instead on every login? if not, how update existing claims without duplicating them?

i'm doing on every login in case user has changed profile or other info (and make sure have date token).

i'm curious why add claims main identity of user. user has property called externalclaims, empty , there doesn't appear way update it. seems me better place put these third-party claims, can't life of me find way modify it...

either way, i'm sure i'd have same problem if use code, proper course delete claim on login , add new, or should doing differently?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -