public D2LPrincipal(IAccessToken accessToken) { m_accessToken = accessToken; m_tenantId = new Lazy <Guid>(GetTenantId); m_scopes = new Lazy <List <Scope> >( () => m_accessToken.GetScopes().ToList() ); long userId; if (!m_accessToken.TryGetUserId(out userId)) { m_principalType = PrincipalType.Service; return; } m_userId = userId; long actualUserId; if (!m_accessToken.TryGetActualUserId(out actualUserId)) { // Doing this means that code that wants to ignore // impersonation can do so with less branching. m_actualUserId = userId; return; } m_actualUserId = actualUserId; }
public D2LPrincipal( IAccessToken accessToken ) { m_accessToken = accessToken; m_tenantId = new Lazy<Guid>( GetTenantId ); m_scopes = new Lazy<List<Scope>>( () => m_accessToken.GetScopes().ToList() ); long userId; if ( !m_accessToken.TryGetUserId( out userId ) ) { m_principalType = PrincipalType.Service; return; } m_userId = userId; long actualUserId; if ( !m_accessToken.TryGetActualUserId( out actualUserId ) ) { // Doing this means that code that wants to ignore // impersonation can do so with less branching. m_actualUserId = userId; return; } m_actualUserId = actualUserId; }
public D2LPrincipal( IAccessToken accessToken ) { m_accessToken = accessToken; m_userId = accessToken.GetUserId(); m_tenantId = new Lazy<Guid>( GetTenantId ); m_principalType = string.IsNullOrEmpty( m_userId ) ? PrincipalType.Service : PrincipalType.User; m_scopes = new Lazy<List<Scope>>( () => m_accessToken.GetScopes().ToList() ); }