private Reddit GetRedditObject() { RefreshTokenWebAgent refreshTokenWebAgent; if (AccountManager.ActiveAccount != null && AccountManager.ActiveAccount.Username.ToUpper() != "LOGGED OUT") { refreshTokenWebAgent = new RefreshTokenWebAgent(AccountManager.ActiveAccount.RefreshToken, CLIENT_ID, null, REDIRECT_URL) { UserAgent = USER_AGENT }; return(new Reddit(refreshTokenWebAgent, true)); } else if (SettingsManager.GetSetting(AccountManager.ActiveRefreshTokenKey) != null) { refreshTokenWebAgent = new RefreshTokenWebAgent(SettingsManager.GetSetting(AccountManager.ActiveRefreshTokenKey), CLIENT_ID, null, REDIRECT_URL) { UserAgent = USER_AGENT }; return(new Reddit(refreshTokenWebAgent, true)); } else { return(new Reddit()); //return null; } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { IdentityModelEventSource.ShowPII = true; services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.ExpireTimeSpan = new TimeSpan(0, 0, 10, 00); }) .AddDiscordAuthentication(Config.DiscordId, Config.DiscordSecret) .AddRedditAuthentication(Config.RedditAuthId, Config.RedditAuthSecret) .AddFedoraAuthentication(SessionClaims.FedoraScheme, Config.FasId, Config.FasSecret) .AddRedhatAuthentication(SessionClaims.RedhatScheme, Config.RedhatClientId, Config.RedhatClientSecret, Config.RedhatOidcDiscoveryUri); var webAgent = new RefreshTokenWebAgent(Config.RedditBotRefreshToken, Config.RedditBotId, Config.RedditBotSecret, Config.RedirectUri); services.AddSingleton(webAgent); services.AddDistributedMemoryCache(); services.AddSession(options => { options.Cookie.IsEssential = true; options.Cookie.Name = "Session"; }); services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN"); services.AddSingleton(Config); services.AddSingleton <RoleService>(); services.AddDiscordBot(); services.AddControllersWithViews(); }
public RoleController(RoleService roleService, RefreshTokenWebAgent redditWebAgent) { _roleService = roleService; _redditWebAgent = redditWebAgent; }