Skip to content

Commit

Permalink
changed the dependency file to support Npgsql, created a webapplicati…
Browse files Browse the repository at this point in the history
…on project for testing, Renamed the project
  • Loading branch information
robson-paproski committed Dec 26, 2015
1 parent 66650c0 commit a858ff6
Show file tree
Hide file tree
Showing 120 changed files with 25,026 additions and 74 deletions.
9 changes: 8 additions & 1 deletion AspNetIdentity3PostgreSQL.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AspNetIdentity3PostgreSQL", "src\AspNetIdentity3PostgreSQL\AspNetIdentity3PostgreSQL.xproj", "{0B21FC24-FAA1-4496-9E86-1B77F0A18A15}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AspNet.Identity.PostgreSQL", "src\AspNetIdentity3PostgreSQL\AspNet.Identity.PostgreSQL.xproj", "{0B21FC24-FAA1-4496-9E86-1B77F0A18A15}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "WebTest", "src\WebTest\WebTest.xproj", "{877369D7-D17B-4B02-9385-47CEE6E2784D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -22,11 +24,16 @@ Global
{0B21FC24-FAA1-4496-9E86-1B77F0A18A15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B21FC24-FAA1-4496-9E86-1B77F0A18A15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B21FC24-FAA1-4496-9E86-1B77F0A18A15}.Release|Any CPU.Build.0 = Release|Any CPU
{877369D7-D17B-4B02-9385-47CEE6E2784D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{877369D7-D17B-4B02-9385-47CEE6E2784D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{877369D7-D17B-4B02-9385-47CEE6E2784D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{877369D7-D17B-4B02-9385-47CEE6E2784D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0B21FC24-FAA1-4496-9E86-1B77F0A18A15} = {F031D30B-35A0-432F-8E84-943BC9E3B34F}
{877369D7-D17B-4B02-9385-47CEE6E2784D} = {F031D30B-35A0-432F-8E84-943BC9E3B34F}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>0b21fc24-faa1-4496-9e86-1b77f0a18a15</ProjectGuid>
<RootNamespace>AspNetIdentity3PostgreSQL</RootNamespace>
<RootNamespace>AspNet.Identity.PostgreSQL</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetIdentity3PostgreSQL/IdentityRole.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;

namespace AspNetIdentity3PostgreSQL
namespace AspNet.Identity.PostgreSQL
{

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetIdentity3PostgreSQL/IdentityRoleClaim.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AspNetIdentity3PostgreSQL
namespace AspNet.Identity.PostgreSQL
{
/// <summary>
/// Represents a claim that is granted to all users within a role.
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetIdentity3PostgreSQL/IdentityUser.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;

namespace AspNetIdentity3PostgreSQL
namespace AspNet.Identity.PostgreSQL
{
public class IdentityUser : IdentityUser<Guid>
{
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetIdentity3PostgreSQL/IdentityUserClaim.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AspNetIdentity3PostgreSQL
namespace AspNet.Identity.PostgreSQL
{
/// <summary>
/// Represents a claim that a user possesses.
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetIdentity3PostgreSQL/IdentityUserLogin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AspNetIdentity3PostgreSQL
namespace AspNet.Identity.PostgreSQL
{
/// <summary>
/// Default implementation of UserLogin using Guid
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetIdentity3PostgreSQL/IdentityUserRole.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace AspNetIdentity3PostgreSQL
namespace AspNet.Identity.PostgreSQL
{
/// <summary>
/// Default implementation of IdentityUserRole using a Guid as primary key
Expand Down
7 changes: 4 additions & 3 deletions src/AspNetIdentity3PostgreSQL/PostgreSQLDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Threading;
using Microsoft.Extensions.Configuration;

namespace AspNetIdentity3PostgreSQL
namespace AspNet.Identity.PostgreSQL
{
/// <summary>
/// Class that encapsulates PostgreSQL database connections and CRUD operations.
Expand All @@ -13,7 +13,7 @@ public class PostgreSQLDatabase : IDisposable
{
private Npgsql.NpgsqlConnection _connection;

/// Default constructor which uses the "DefaultConnection" connectionString, often located in web.config.
/// Default constructor which uses the "DefaultConnection" connectionString
/// </summary>
public PostgreSQLDatabase()
: this("DefaultConnection")
Expand All @@ -30,7 +30,8 @@ public PostgreSQLDatabase(string connectionStringName)
new ConfigurationBuilder()
.AddJsonFile("config.json");
var config = configbuilder.Build();
var connectionString = config.Get(connectionStringName);
var connectionString = config[connectionStringName];

_connection = new Npgsql.NpgsqlConnection(connectionString);
}

Expand Down
4 changes: 2 additions & 2 deletions src/AspNetIdentity3PostgreSQL/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AspNetIdentity3PostgreSQL")]
[assembly: AssemblyTitle("AspNet.Identity.PostgreSQL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AspNetIdentity3PostgreSQL")]
[assembly: AssemblyProduct("AspNet.Identity.PostgreSQL")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Expand Down
25 changes: 13 additions & 12 deletions src/AspNetIdentity3PostgreSQL/Stores/RoleStore.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Linq;
using AspNetIdentity3PostgreSQL.Tables;
using AspNet.Identity.PostgreSQL.Tables;
using Microsoft.AspNet.Identity;
using System.Threading;
using System.Threading.Tasks;

namespace AspNetIdentity3PostgreSQL.Stores
namespace AspNet.Identity.PostgreSQL.Stores
{
/// <summary>
/// Class that implements the key ASP.NET Identity role store iterfaces.
Expand All @@ -30,7 +30,8 @@ public IQueryable<TRole> Roles
/// </summary>
public RoleStore()
{
new RoleStore<TRole>(new PostgreSQLDatabase());
this.Database = new PostgreSQLDatabase();
this.roleTable = new RoleTable(Database);
}

/// <summary>
Expand All @@ -45,47 +46,47 @@ public RoleStore(PostgreSQLDatabase database)

public void Dispose()
{
throw new NotImplementedException();
//throw new NotImplementedException();
}

public Task<IdentityResult> CreateAsync(TRole role, CancellationToken cancellationToken)
{
throw new NotImplementedException();
return Task.FromResult(IdentityResult.Success);
}

public Task<IdentityResult> UpdateAsync(TRole role, CancellationToken cancellationToken)
{
throw new NotImplementedException();
return Task.FromResult(IdentityResult.Success);
}

public Task<IdentityResult> DeleteAsync(TRole role, CancellationToken cancellationToken)
{
throw new NotImplementedException();
return Task.FromResult(IdentityResult.Success);
}

public Task<string> GetRoleIdAsync(TRole role, CancellationToken cancellationToken)
{
throw new NotImplementedException();
return Task.FromResult("");
}

public Task<string> GetRoleNameAsync(TRole role, CancellationToken cancellationToken)
{
throw new NotImplementedException();
return Task.FromResult("");
}

public Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken)
{
throw new NotImplementedException();
return Task.FromResult(0);
}

public Task<string> GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken)
{
throw new NotImplementedException();
return Task.FromResult("");
}

public Task SetNormalizedRoleNameAsync(TRole role, string normalizedName, CancellationToken cancellationToken)
{
throw new NotImplementedException();
return Task.FromResult(0);
}

public Task<TRole> FindByIdAsync(string roleId, CancellationToken cancellationToken)
Expand Down
46 changes: 21 additions & 25 deletions src/AspNetIdentity3PostgreSQL/Stores/UserStore.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
using System;
using System.Collections;
using System.Linq;
using AspNetIdentity3PostgreSQL.Tables;
using AspNet.Identity.PostgreSQL.Tables;
using Microsoft.AspNet.Identity;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;


namespace AspNetIdentity3PostgreSQL.Stores
namespace AspNet.Identity.PostgreSQL.Stores
{
/// <summary>
/// Class that implements the key ASP.NET Identity user store interfaces
/// </summary>
public class UserStore<TUser, TRole> : IUserLoginStore<TUser>,
public class UserStore<TUser> : IUserLoginStore<TUser>,
IUserRoleStore<TUser>,
IUserClaimStore<TUser>,
IUserPasswordStore<TUser>,
Expand All @@ -25,9 +23,7 @@ public class UserStore<TUser, TRole> : IUserLoginStore<TUser>,
IUserLockoutStore<TUser>,
IUserPhoneNumberStore<TUser>,
IQueryableUserStore<TUser>,
IUserTwoFactorStore<TUser>
where TUser : IdentityUser
where TRole : IdentityRole
IUserTwoFactorStore<TUser> where TUser : IdentityUser
{
private readonly UserTable<TUser> _userTable;
private readonly RoleTable _roleTable;
Expand All @@ -40,11 +36,18 @@ public class UserStore<TUser, TRole> : IUserLoginStore<TUser>,
/// <summary>
/// Default constructor that initializes a new PostgreSQLDatabase instance using the Default Connection string.
/// </summary>
public UserStore()
public UserStore()
{
new UserStore<TUser, TRole>(new PostgreSQLDatabase());
Database = new PostgreSQLDatabase();
_userTable = new UserTable<TUser>(Database);
_roleTable = new RoleTable(Database);
_userRolesTable = new UserRolesTable(Database);
_userClaimsTable = new UserClaimsTable(Database);
_userLoginsTable = new UserLoginsTable(Database);
}



/// <summary>
/// Constructor that takes a PostgreSQLDatabase as argument.
/// </summary>
Expand Down Expand Up @@ -378,7 +381,7 @@ public UserStore(PostgreSQLDatabase database)
{
throw new ArgumentNullException(nameof(user));
}
return _userRolesTable.FindByUserId(user.Id.ToString()); ;
return _userRolesTable.FindByUserId(user.Id); ;
}

/// <summary>
Expand Down Expand Up @@ -444,8 +447,10 @@ public void Dispose()
{
throw new ArgumentNullException(nameof(user));
}

return _userClaimsTable.FindByUserId(user.Id.ToString()).Claims as IList<Claim>;
var list = _userClaimsTable.FindByUserId(user.Id);
if (list == null)
return null;
return list.Claims.ToList();
}


Expand All @@ -469,7 +474,7 @@ public void Dispose()
}
foreach (var claim in claims)
{
_userClaimsTable.Insert(claim, user.Id.ToString());
_userClaimsTable.Insert(claim, user.Id);
}
return Task.FromResult(false);
}
Expand Down Expand Up @@ -594,7 +599,7 @@ public virtual async Task RemoveLoginAsync(TUser user, string loginProvider, str
}


return _userLoginsTable.FindByUserId(user.Id.ToString());
return _userLoginsTable.FindByUserId(user.Id);
}

/// <summary>
Expand Down Expand Up @@ -652,7 +657,6 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.EmailConfirmed = confirmed;
_userTable.Update(user);
return Task.FromResult(0);
}

Expand All @@ -672,7 +676,6 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.Email = email;
_userTable.Update(user);
return Task.FromResult(0);
}

Expand Down Expand Up @@ -783,7 +786,6 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.LockoutEnd = lockoutEnd;
_userTable.Update(user);
return Task.FromResult(0);
}

Expand All @@ -802,7 +804,6 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.AccessFailedCount++;
_userTable.Update(user);
return Task.FromResult(user.AccessFailedCount);
}

Expand All @@ -822,7 +823,7 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.AccessFailedCount = 0;
_userTable.Update(user);

return Task.FromResult(0);
}

Expand Down Expand Up @@ -878,7 +879,6 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.LockoutEnabled = enabled;
_userTable.Update(user);
return Task.FromResult(0);
}

Expand All @@ -898,7 +898,6 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.PhoneNumber = phoneNumber;
_userTable.Update(user);
return Task.FromResult(0);
}

Expand Down Expand Up @@ -955,7 +954,6 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.PhoneNumberConfirmed = confirmed;
_userTable.Update(user);
return Task.FromResult(0);
}

Expand All @@ -975,7 +973,6 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.SecurityStamp = stamp;
_userTable.Update(user);
return Task.FromResult(0);
}

Expand Down Expand Up @@ -1013,7 +1010,6 @@ public virtual async Task<TUser> FindByLoginAsync(string loginProvider, string p
throw new ArgumentNullException(nameof(user));
}
user.TwoFactorEnabled = enabled;
_userTable.Update(user);
return Task.FromResult(0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/AspNetIdentity3PostgreSQL/StringExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AspNetIdentity3PostgreSQL
namespace AspNet.Identity.PostgreSQL
{
public static class StringExtension
{
Expand Down
Loading

0 comments on commit a858ff6

Please sign in to comment.