mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 17:22:15 +00:00
fix user provider
This commit is contained in:
parent
f87ad0550b
commit
41ced12e3b
1 changed files with 15 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Identity.Owin;
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using Microsoft.Owin;
|
||||
using Microsoft.Owin.Security.Cookies;
|
||||
using Microsoft.Owin.Security.Google;
|
||||
|
@ -14,6 +16,10 @@ public partial class Startup
|
|||
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
|
||||
public void ConfigureAuth(IAppBuilder app)
|
||||
{
|
||||
var idProvider = new UniteUserIdProvider();
|
||||
|
||||
GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => idProvider);
|
||||
|
||||
app.MapSignalR();
|
||||
|
||||
|
||||
|
@ -70,4 +76,13 @@ public void ConfigureAuth(IAppBuilder app)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
public class UniteUserIdProvider : IUserIdProvider
|
||||
{
|
||||
public string GetUserId(IRequest request)
|
||||
{
|
||||
var db = new ApplicationDbContext();
|
||||
return db.Users.FirstOrDefault(x => x.UserName == request.User.Identity.Name).Id;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue