當前位置: 首頁>>代碼示例>>C#>>正文


C# AuthContext類代碼示例

本文整理匯總了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>();
 }
開發者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


注:本文中的AuthContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。