Example #1
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            if (ApplicationSettingsHelper.AppSetting <bool>("use_recaptcha"))
            {
                var recaptchaIsValid = await ValidateRecaptch(context);

                if (!recaptchaIsValid)
                {
                    return;
                }
            }

            var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();

            ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("مجوز نامعتبر", "نام کاربری یا رمز عبور اشتباه است");
                return;
            }

            ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                OAuthDefaults.AuthenticationType);

            ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                  CookieAuthenticationDefaults.AuthenticationType);

            AuthenticationProperties properties = CreateProperties(user.UserName);
            AuthenticationTicket     ticket     = new AuthenticationTicket(oAuthIdentity, properties);

            context.Validated(ticket);
            context.Request.Context.Authentication.SignIn(cookiesIdentity);
        }
 public IPagedListRequest <TEntity> Create(int?pageSize, int?pageNumber, string order, string orderBy)
 {
     this.SetOrder(orderBy, order);
     this.PageNumber = pageNumber ?? 1;
     this.PageSize   = pageSize ?? ApplicationSettingsHelper.AppSetting <int>("Application.DefaultPageSize");
     return(this);
 }
Example #3
0
        private async Task <BankPaymentRequestResponseDto> GetZarinPalReferenceId(InvoiceDto invoice, int invoiceAmount, string transactionNumber, string userId, BankNameType bankName)
        {
            try
            {
                System.Net.ServicePointManager.Expect100Continue = false;
                PaymentGatewayImplementationServicePortTypeClient zp = new PaymentGatewayImplementationServicePortTypeClient();
                string authority;

                var callBackUrl = ApplicationSettings.FinancialSettings.ZarinPal.DefaultCallBackUrl;

                int status = zp.PaymentRequest(
                    ApplicationSettingsHelper.AppSetting("ZarinPal.MerchantCode"),
                    (int)invoiceAmount,
                    $"Invoice #{invoice.InvoiceNumber}",
                    ApplicationSettings.DefaultEmailAddress,
                    ApplicationSettings.DefaultMobileNumber,
                    callBackUrl,
                    out authority);

                if (status == 100)
                {
                    var authorityUrl = ZarinPalHelper.GetUrl(authority);
                    var transaction  = new FinanceTransaction(invoice.Id, transactionNumber, userId, bankName, authority);

                    UnitOfWork.FinanceTransactionRepository.Create(transaction);
                    await UnitOfWork.SaveAsync();

                    return(new BankPaymentRequestResponseDto()
                    {
                        Response = authorityUrl,
                        PaymentRequestType = PaymentRequestType.Url,
                        PaymentRequestTypeTitle = "URL"
                    });
                }
                else
                {
                    return(new BankPaymentRequestResponseDto()
                    {
                        HasError = true,
                        Error = BankResultException(status.ToString(), BankNameType.ZarinPal)
                    });
                }
            }
            catch
            {
                return(new BankPaymentRequestResponseDto()
                {
                    HasError = true,
                    Error = BankResultException("", BankNameType.ZarinPal)
                });
            }
        }
 protected string AppSettings(string key)
 {
     return(ApplicationSettingsHelper.AppSetting(key));
 }
 protected T AppSettings <T>(string key)
 {
     return(ApplicationSettingsHelper.AppSetting <T>(key));
 }
Example #6
0
 public TType GetServerSetting <TType>(string appSettingKey)
 {
     return(ApplicationSettingsHelper.AppSetting <TType>(appSettingKey));
 }
Example #7
0
 public string GetServerSetting(string appSettingKey)
 {
     return(ApplicationSettingsHelper.AppSetting(appSettingKey));
 }
Example #8
0
 public string GetClientAppSetting(string appSettingKey)
 {
     return(ApplicationSettingsHelper.AppSetting("client." + appSettingKey));
 }