Ejemplo n.º 1
0
 public UserController(UserManager <ApplicationUserModel> userManager, SignInManager <ApplicationUserModel> signInManager, IOptions <ApplicationSettings> appSettings, APIDbContext context)
 {
     _userManager   = userManager;
     _singInManager = signInManager;
     _appSettings   = appSettings.Value;
     _context       = context;
 }
Ejemplo n.º 2
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            try
            {
                //retrieve your user from database. ex:
                //var user = await userService.Authenticate(context.UserName, context.Password);
                APIDbContext db        = new APIDbContext();
                object[]     paremeter =
                {
                    new SqlParameter("@UserName", context.UserName),
                    new SqlParameter("@Password", context.Password)
                };
                var user = db.Database.SqlQuery <USER_INFORMATION>("sp_Login @UserName, @Password", paremeter).ToList();

                var identity = new ClaimsIdentity(context.Options.AuthenticationType);

                identity.AddClaim(new Claim(ClaimTypes.Name, user.FirstOrDefault().UserName));
                identity.AddClaim(new Claim(ClaimTypes.Email, "*****@*****.**"));
                var rolesTechnicalNamesUser = new List <string>();
                var principal = new GenericPrincipal(identity, rolesTechnicalNamesUser.ToArray());

                Thread.CurrentPrincipal = principal;

                context.Validated(identity);
            }
            catch (Exception ex)
            {
                context.SetError("invalid_grant", "message");
            }
        }
Ejemplo n.º 3
0
 public AccountController(APIDbContext dbContext, RoleManager <IdentityRole> RoleManager, UserManager <ApplicationUser> UserManager, SignInManager <ApplicationUser> signInManager)
     : base(dbContext, signInManager, UserManager)
 {
     this.dbContext   = dbContext;
     this.RoleManager = RoleManager;
     this.UserManager = UserManager;
 }
Ejemplo n.º 4
0
 public HomeController(
     IStringLocalizer <HomeController> localizer,
     APIDbContext dbContext)
 {
     _localizer = localizer;
     _dbContext = dbContext;
 }
Ejemplo n.º 5
0
 public ConnectController(APIDbContext dbContext, SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> user, TokenHelper TokenHelper)
     : base(dbContext, signInManager, user)
 {
     this.dbContext     = dbContext;
     this.signInManager = signInManager;
     userManage         = user;
     tokenHelper        = TokenHelper;
 }
Ejemplo n.º 6
0
 public HomeController(
     IStringLocalizer <HomeController> localizer,
     RSAService rsaService,
     APIDbContext dbContext)
 {
     _localizer  = localizer;
     _rsaService = rsaService;
     _dbContext  = dbContext;
 }
Ejemplo n.º 7
0
 public GrantChecker(
     APIDbContext context,
     DeveloperApiService developerApiService,
     ACTokenManager tokenManager)
 {
     _dbContext           = context;
     _developerApiService = developerApiService;
     _tokenManager        = tokenManager;
 }
Ejemplo n.º 8
0
 public ApiController(
     UserManager <APIUser> userManager,
     APIDbContext context,
     DeveloperApiService developerApiService,
     ACTokenManager tokenManager)
 {
     _userManager         = userManager;
     _dbContext           = context;
     _developerApiService = developerApiService;
     _tokenManager        = tokenManager;
 }
Ejemplo n.º 9
0
 public UserController(
     UserManager <APIUser> userManager,
     APIDbContext context,
     ConfirmationEmailSender emailSender,
     GrantChecker grantChecker)
 {
     _userManager  = userManager;
     _dbContext    = context;
     _emailSender  = emailSender;
     _grantChecker = grantChecker;
 }
Ejemplo n.º 10
0
 public ApiController(
     UserManager <APIUser> userManager,
     ILoggerFactory loggerFactory,
     APIDbContext context,
     DeveloperApiService developerApiService,
     ACTokenManager tokenManager)
 {
     _userManager = userManager;
     loggerFactory.CreateLogger <ApiController>();
     _dbContext           = context;
     _developerApiService = developerApiService;
     _tokenManager        = tokenManager;
 }
Ejemplo n.º 11
0
 public async virtual Task GrantTargetApp(APIDbContext dbContext, string appId)
 {
     if (!await HasAuthorizedApp(dbContext, appId))
     {
         var appGrant = new AppGrant
         {
             AppID     = appId,
             APIUserId = Id
         };
         dbContext.LocalAppGrant.Add(appGrant);
         await dbContext.SaveChangesAsync();
     }
 }
Ejemplo n.º 12
0
        public async Task AllClean(APIDbContext dbContext)
        {
            try
            {
                await ClearTimeOutOAuthPack(dbContext);

                _logger.LogInformation("Clean finished!");
            }
            catch (Exception e)
            {
                _logger.LogCritical(e.Message);
            }
        }
Ejemplo n.º 13
0
 public PasswordController(
     APIDbContext dbContext,
     ILoggerFactory loggerFactory,
     ConfirmationEmailSender emailSender,
     UserManager <APIUser> userManager,
     APISMSSender smsSender)
 {
     _dbContext   = dbContext;
     _emailSender = emailSender;
     _userManager = userManager;
     _smsSender   = smsSender;
     _logger      = loggerFactory.CreateLogger <ApiController>();
 }
Ejemplo n.º 14
0
 public HomeController(
     UserManager <APIUser> userManager,
     SignInManager <APIUser> signInManager,
     ILoggerFactory loggerFactory,
     APIDbContext _context,
     IStringLocalizer <HomeController> localizer)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _logger        = loggerFactory.CreateLogger <HomeController>();
     _dbContext     = _context;
     _localizer     = localizer;
 }
Ejemplo n.º 15
0
        public async virtual Task <OAuthPack> GeneratePack(APIDbContext dbContext, string appId)
        {
            var pack = new OAuthPack
            {
                Code       = Math.Abs(Guid.NewGuid().GetHashCode()),
                UserId     = Id,
                ApplyAppId = appId
            };

            dbContext.OAuthPack.Add(pack);
            await dbContext.SaveChangesAsync();

            return(pack);
        }
Ejemplo n.º 16
0
 public HomeController(
     UserManager <APIUser> userManager,
     SignInManager <APIUser> signInManager,
     IEmailSender emailSender,
     ISmsSender smsSender,
     ILoggerFactory loggerFactory,
     APIDbContext _context)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _emailSender   = emailSender;
     _smsSender     = smsSender;
     _logger        = loggerFactory.CreateLogger <HomeController>();
     _dbContext     = _context;
 }
Ejemplo n.º 17
0
        public async virtual Task GrantTargetApp(APIDbContext DbContext, string AppId)
        {
            if (await HasAuthorizedApp(DbContext, AppId))
            {
                return;
            }
            var AppGrant = new AppGrant
            {
                AppID     = AppId,
                APIUserId = this.Id
            };

            DbContext.LocalAppGrant.Add(AppGrant);
            await DbContext.SaveChangesAsync();
        }
Ejemplo n.º 18
0
 public AccountController(
     ACTokenManager tokenManager,
     DeveloperApiService apiService,
     APIDbContext dbContext,
     SignInManager <APIUser> signInManager,
     UserManager <APIUser> userManager,
     ConfirmationEmailSender emailSender)
 {
     _tokenManager  = tokenManager;
     _apiService    = apiService;
     _dbContext     = dbContext;
     _signInManager = signInManager;
     _userManager   = userManager;
     _emailSender   = emailSender;
 }
Ejemplo n.º 19
0
 public ApiController(
     UserManager <APIUser> userManager,
     SignInManager <APIUser> signInManager,
     ILoggerFactory loggerFactory,
     APIDbContext _context,
     IStringLocalizer <ApiController> localizer,
     DeveloperApiService developerApiService)
 {
     _userManager         = userManager;
     _signInManager       = signInManager;
     _logger              = loggerFactory.CreateLogger <ApiController>();
     _dbContext           = _context;
     _localizer           = localizer;
     _developerApiService = developerApiService;
 }
Ejemplo n.º 20
0
        public async virtual Task <OAuthPack> GeneratePack(APIDbContext DbContext, string AppId)
        {
            var pack = new OAuthPack
            {
                AccessTokens = new List <AccessToken>(),
                Code         = (Id + DateTime.Now.ToString()).GetHashCode(),
                UserId       = this.Id,
                ApplyAppId   = AppId
            };

            DbContext.OAuthPack.Add(pack);
            await DbContext.SaveChangesAsync();

            return(pack);
        }
Ejemplo n.º 21
0
 public OAuthController(
     UserManager <APIUser> userManager,
     SignInManager <APIUser> signInManager,
     ILoggerFactory loggerFactory,
     APIDbContext context,
     DeveloperApiService developerApiService,
     ACTokenManager tokenManager)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _logger        = loggerFactory.CreateLogger <OAuthController>();
     _dbContext     = context;
     _apiService    = developerApiService;
     _tokenManager  = tokenManager;
 }
Ejemplo n.º 22
0
 public ApiController(
     UserManager <APIUser> userManager,
     SignInManager <APIUser> signInManager,
     IEmailSender emailSender,
     ISmsSender smsSender,
     ILoggerFactory loggerFactory,
     APIDbContext _context,
     IStringLocalizer <ApiController> localizer)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _emailSender   = emailSender;
     _smsSender     = smsSender;
     _logger        = loggerFactory.CreateLogger <ApiController>();
     _dbContext     = _context;
     _localizer     = localizer;
 }
Ejemplo n.º 23
0
 public ItemsController(APIDbContext context, IItemRepository cr)
 {
     _context         = context;
     _cr              = cr;
     _cr.APIDbContext = context;
     //Order order = _context.Orders.Where(s => s.OrderID == 3).FirstOrDefault();
     //_context.Items.Add(
     //      new Item
     //      {
     //          Amount = 10,
     //          Order = order,
     //          qty = 1,
     //          Product = null
     //      }
     //      );
     _context.SaveChanges();
 }
Ejemplo n.º 24
0
 public UserController(
     UserManager <APIUser> userManager,
     ILoggerFactory loggerFactory,
     APIDbContext context,
     AiurEmailSender emailSender,
     APISMSSender smsSender,
     ServiceLocation serviceLocation,
     GrantChecker grantChecker)
 {
     _userManager     = userManager;
     _logger          = loggerFactory.CreateLogger <ApiController>();
     _dbContext       = context;
     _emailSender     = emailSender;
     _smsSender       = smsSender;
     _serviceLocation = serviceLocation;
     _grantChecker    = grantChecker;
 }
Ejemplo n.º 25
0
    public Guid UpsertRequest(
        TInput input,
        MasterSection masterSection,
        RequestInput requestInputs,
        APIDbContext dbContext)
    {
        Guid id = Guid.NewGuid();

        var library = CreateLibrary(input, masterSection);

        dbContext.Set <TLibrary>().Add(library);
        dbContext.SaveChanges();

        var request = RequestHelper.CreateRequest(masterSection, library.Id, requestInputs, dbContext);

        dbContext.Requests.Add(request);
        dbContext.SaveChanges();
        return(request.Id);
    }
Ejemplo n.º 26
0
 public UserController(
     UserManager <APIUser> userManager,
     SignInManager <APIUser> signInManager,
     ILoggerFactory loggerFactory,
     APIDbContext _context,
     IStringLocalizer <ApiController> localizer,
     AiurEmailSender emailSender,
     AiurSMSSender smsSender,
     DeveloperApiService developerApiService,
     ServiceLocation serviceLocation)
 {
     _userManager         = userManager;
     _signInManager       = signInManager;
     _logger              = loggerFactory.CreateLogger <ApiController>();
     _dbContext           = _context;
     _localizer           = localizer;
     _emailSender         = emailSender;
     _smsSender           = smsSender;
     _developerApiService = developerApiService;
     _serviceLocation     = serviceLocation;
 }
Ejemplo n.º 27
0
 public OrderRepository(APIDbContext APIDbContext)
 {
     this.APIDbContext = APIDbContext;
 }
Ejemplo n.º 28
0
 public AdminController(UserManager <ApplicationUserModel> userManager, APIDbContext context)
 {
     _userManager = userManager;
     _context     = context;
 }
Ejemplo n.º 29
0
 public BankController(APIDbContext context)
 {
     _context = context;
 }
Ejemplo n.º 30
0
 public CardTypeRepository(APIDbContext APIDbContext)
 {
     this.APIDbContext = APIDbContext;
 }