本文整理汇总了C#中AuthContext类的典型用法代码示例。如果您正苦于以下问题:C# AuthContext类的具体用法?C# AuthContext怎么用?C# AuthContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthContext类属于命名空间,在下文中一共展示了AuthContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>();
}
示例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;
}
}
示例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);
}
示例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));
}
示例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;
}
示例6: LoginViewModel
public LoginViewModel(DataRetrieval dataRetrieval, AuthContext authContext)
{
_dataRetrieval = dataRetrieval;
_authContext = authContext;
LoginCommand = new DelegateCommand(LoginExecuted, LoginCanExecute);
UserName = "[email protected]";
Password = "Testing123";
}
示例7: Get
public AuthContext Get()
{
if (dataContext == null)
{
dataContext = new AuthContext();
}
return dataContext;
}
示例8: AuthContextPop
private void AuthContextPop(AuthContext ctx)
{
if (ctx.Parse != null)
{
ctx.Parse._authContext = ctx.Context;
ctx.Parse = null;
}
}
示例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);
}
示例10: UserRepository
public UserRepository()
{
_authContext = new AuthContext();
_userManager = new UserManager<User>(new UserStore<User>(_authContext));
}
示例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));
}
示例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();
}
示例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;
}
示例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;
}
示例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
};
}