Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend Microsoft.AspNet.Identity.IUser<TKey>

I am trying to implement a registration prozess with email confirmation for my web application. I am using a IdentityServer3.AspNetIdentity service.

public class AspNetIdentityUserService<TUser, TKey> : UserServiceBase
    where TUser : class, Microsoft.AspNet.Identity.IUser<TKey>, new()
    where TKey : IEquatable<TKey>
{

My problem is the TUser which required the Microsoft.AspNet.Identity.IUser interface. In my implemented function the incoming user context is the right one but I do not have access to all attributes which you can see in the following two images.

enter image description here

enter image description here

http://img5.fotos-hochladen.net/uploads/b6aa42c662dd1kv063h4g5p.png http://img5.fotos-hochladen.net/uploads/d75b1e6462dd1wi9clqj6e7.png

Do you know how can I extend the Microsoft.AspNet.Identity.IUser to the effect that I have access to the attributes Lastname and Firstname?

like image 673
ANEDev Avatar asked Nov 23 '25 18:11

ANEDev


1 Answers

Here TUser is a custom implemented class in IdentityServer3 which is inherited from IdentityUser for user identity.

You are not able to access these properties because TUser is object of IdentityServer3.Host.WebHost.AspId.User represented by base class IdentityUser or IUser.

The Quickwatch would show the object properties but it wouldn't appear in intellisense.

You need to cast the TUser to IdentityServer3.Host.WebHost.AspId.User.

var user = new TUser() as IdentityServer3.Host.WebHost.AspId.User;
user.FirstName = "Tester";
user.LastName = "Doer";

This should give you the workaround.

like image 137
vendettamit Avatar answered Nov 26 '25 10:11

vendettamit