本文整理汇总了C#中AuthContext类的典型用法代码示例。如果您正苦于以下问题:C# AuthContext类的具体用法?C# AuthContext怎么用?C# AuthContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthContext类属于命名空间,在下文中一共展示了AuthContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AuthRepository
public AuthRepository(IContextFactory contextFactory)
{
_contextFactory = contextFactory;
_authContext = new AuthContext();
_userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_authContext));
_userManager.UserTokenProvider = new TotpSecurityStampBasedTokenProvider<IdentityUser, string>();
}
开发者ID:Eimovas,项目名称:Tournament.API,代码行数:7,代码来源:AuthRepository.cs
示例2: sqlite3AuthContextPop
/*
** Pop an authorization context that was previously pushed
** by sqlite3AuthContextPush
*/
void sqlite3AuthContextPop(AuthContext *pContext)
{
if( pContext->pParse ){
pContext->pParse->zAuthContext = pContext->zAuthContext;
pContext->pParse = 0;
}
}
开发者ID:RainsSoft,项目名称:CsharpSQLite,代码行数:11,代码来源:auth_c.cs
示例3: GrantResourceOwnerCredentials
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
//context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
AuthContext _auth = new AuthContext();
UserManager<IdentityUser> _userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_auth));
RoleManager<IdentityRole> _roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(_auth));
AuthRepository _repo = new AuthRepository();
IdentityUser user = await _repo.FindUser(context.UserName, context.Password);
if (user == null)
{
context.SetError("invalid_grant", "The user name or password is incorrect.");
return;
}
var userIdentity = await _userManager.CreateIdentityAsync(user, context.Options.AuthenticationType);
foreach (IdentityUserRole role in user.Roles)
{
var iRole = _roleManager.FindById(role.RoleId);
userIdentity.AddClaim(new Claim(ClaimTypes.Role, iRole.Name));
}
userIdentity.AddClaim(new Claim("sub", context.UserName));
userIdentity.AddClaim(new Claim("role", "user"));
var ticket = new AuthenticationTicket(userIdentity, null);
context.Validated(ticket);
}
开发者ID:NicoVerbeeke,项目名称:BackEndZomer2015,代码行数:33,代码来源:SimpleAuthorizationServerProvider.cs
示例4: AuthRepository
public AuthRepository()
{
_db = new DataContext();
_ctx = new AuthContext();
_userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_ctx));
_roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(_ctx));
}
开发者ID:NicoVerbeeke,项目名称:BackEndZomer2015,代码行数:7,代码来源:AuthRepository.cs
示例5: Get
public async Task<Confirmed> Get(string id)
{
string uid = Encoding.ASCII.GetString(HttpServerUtility.UrlTokenDecode(id));
Confirmed c = new Confirmed();
string fullstring = Util.Decrypt(uid, true);
int index = fullstring.IndexOf("{GreenTime}");
string UserName = fullstring.Substring(0, index);
string Password = fullstring.Substring(index + 11);
AuthContext context = new AuthContext();
IdentityUser user = null;
People ps = context.Peoples.Where(p => p.email == UserName).SingleOrDefault();
ps.emailConfirmed = true;
using (AuthRepository _repo = new AuthRepository())
{
user = await _repo.FindUser(UserName, Password);
if (user != null)
{
context.updatePeople(ps);
c.isConfirmed = true;
return c;
}
}
return c;
}
开发者ID:rchaudharymore,项目名称:pDotAngular,代码行数:32,代码来源:ConfirmEmailController.cs
示例6: LoginViewModel
public LoginViewModel(DataRetrieval dataRetrieval, AuthContext authContext)
{
_dataRetrieval = dataRetrieval;
_authContext = authContext;
LoginCommand = new DelegateCommand(LoginExecuted, LoginCanExecute);
UserName = "[email protected]";
Password = "Testing123";
}
开发者ID:Zaknafeyn,项目名称:pitneytest,代码行数:8,代码来源:LoginViewModel.cs
示例7: Get
public AuthContext Get()
{
if (dataContext == null)
{
dataContext = new AuthContext();
}
return dataContext;
}
开发者ID:hugoestevam,项目名称:DiarioAcademia,代码行数:8,代码来源:AuthFactory.cs
示例8: AuthContextPop
private void AuthContextPop(AuthContext ctx)
{
if (ctx.Parse != null)
{
ctx.Parse._authContext = ctx.Context;
ctx.Parse = null;
}
}
开发者ID:JiujiangZhu,项目名称:feaserver,代码行数:8,代码来源:Parse+Auth.cs
示例9: ApplicationRepository
public ApplicationRepository()
{
_ctx = new AuthContext();
_userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_ctx));
RefreshTokens = new RefreshTokenRepository(_ctx);
Audiences = new AudienceRepository(_ctx);
Files = new FileRepository(_ctx);
}
开发者ID:Fanuer,项目名称:EventCorp,代码行数:8,代码来源:ApplicationRepository.cs
示例10: UserRepository
public UserRepository()
{
_authContext = new AuthContext();
_userManager = new UserManager<User>(new UserStore<User>(_authContext));
}
开发者ID:slavasubot,项目名称:Market.Web,代码行数:8,代码来源:UserRepository.cs
示例11: AuthRepository
//private UserManager<MemberUser> _userInfo;
public AuthRepository()
{
_ctx = new AuthContext();
_userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_ctx));
_roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(_ctx));
//_userroleManager = new UserManager<IdentityUserRole>();
//_userInfo = new UserManager<MemberUser>(new UserStore<MemberUser>(_ctx));
}
开发者ID:tradaduong2811,项目名称:KNSERS_BackEnd,代码行数:11,代码来源:AuthRepository.cs
示例12: AccountController
public AccountController()
{
_repo = new AuthRepository();
_ctx = new AuthContext();
UserStore<UserModel> userStore = new UserStore<UserModel>(_ctx);
_userManager = new UserManager<UserModel>(userStore);
_userBCA = new UserBusinessComponentAdapter();
}
开发者ID:NicoVerbeeke,项目名称:EVA18-backend,代码行数:10,代码来源:AccountController.cs
示例13: sqlite3AuthContextPush
/*
** Push an authorization context. After this routine is called, the
** zArg3 argument to authorization callbacks will be zContext until
** popped. Or if pParse==0, this routine is a no-op.
*/
void sqlite3AuthContextPush(
Parse *pParse,
AuthContext *pContext,
string zContext
)
{
Debug.Assert( pParse );
pContext->pParse = pParse;
pContext->zAuthContext = pParse->zAuthContext;
pParse->zAuthContext = zContext;
}
开发者ID:RainsSoft,项目名称:CsharpSQLite,代码行数:16,代码来源:auth_c.cs
示例14: UpdateUser
public async Task<IdentityResult> UpdateUser(IdentityUser user)
{
IdentityResult user1 = null;
try
{
_ctx = new AuthContext();
_userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_ctx));
user1 = await _userManager.UpdateAsync(user);
}
catch (Exception ex) { }
return user1;
}
开发者ID:rchaudharymore,项目名称:pDotAngular,代码行数:12,代码来源:AuthRepository.cs
示例15: AuthRepository
public AuthRepository()
{
_ctx = new AuthContext();
_userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_ctx));
_userManager.PasswordValidator = new PasswordValidator() {
RequiredLength = 3,
RequireNonLetterOrDigit = false,
RequireDigit = false,
RequireLowercase = false,
RequireUppercase = false
};
}
开发者ID:mofajke,项目名称:geopges,代码行数:12,代码来源:AuthRepository.cs
示例16: AddUserIfNotExists
public static void AddUserIfNotExists(string userName, string pwd)
{
using (var ctx = new AuthContext())
{
using (var userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(ctx)))
{
var userExists = userManager.Users.Any(u => u.UserName == userName);
if (!userExists)
{
userManager.Create(new IdentityUser(userName), pwd);
}
}
}
}
开发者ID:jbijlsma,项目名称:ToDo,代码行数:14,代码来源:TestUserManager.cs
示例17: AuthRepository
public AuthRepository()
{
try
{
_ctx = new AuthContext();
_userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_ctx));
}
catch (Exception ex)
{
System.Diagnostics.Trace.TraceError("AuthRepository Exception.",ex.Message);
//throw;
}
}
开发者ID:liranmotol,项目名称:PickMeUpPlease,代码行数:14,代码来源:AuthRepository.cs
示例18: Get
public IHttpActionResult Get()
{
AuthContext context = new AuthContext();
//ClaimsPrincipal principal = Request.GetRequestContext().Principal as ClaimsPrincipal;
//var Name = ClaimsPrincipal.Current.Identity.Name;
//var Name1 = User.Identity.Name;
//var userName = principal.Claims.Where(c => c.Type == "sub").Single().Value;
return Ok(Helper.createUsers());
}
开发者ID:rchaudharymore,项目名称:pDotAngular,代码行数:14,代码来源:UsersController.cs
示例19: AuthRepository
public AuthRepository()
{
var provider = new DpapiDataProtectionProvider("Microbrew.it");
_ctx = new AuthContext();
//_userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_ctx));
_userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(_ctx))
{
EmailService = new EmailService()
};
_userManager.UserTokenProvider = new DataProtectorTokenProvider<IdentityUser>(provider.Create("ASP.NET Identity"))
{
//Sets the lifespan of the confirm email token and the reset password token.
TokenLifespan = TimeSpan.FromMinutes(1),
};
}
开发者ID:johnfredrik,项目名称:MicrobrewitApi,代码行数:15,代码来源:AuthRespository.cs
示例20: Execute
public void Execute()
{
var container = new WindsorContainer().Install(FromAssembly.This());
GlobalConfiguration.Configuration.Services.Replace(
typeof(IHttpControllerActivator),
new WindsorControllerActivator(container.Kernel));
var locator = new WindsorServiceLocator(container);
ServiceLocator.SetLocatorProvider(() => locator);
var securityContext = new AuthContext();
securityContext.Database.Initialize(true);
var context = new RMSContext();
context.Database.Initialize(true);
}
开发者ID:ehsmohammadi,项目名称:BTE.RMS,代码行数:18,代码来源:Bootstrapper.cs
注:本文中的AuthContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论