diff --git a/src/Ombi.Schedule/JobSetup.cs b/src/Ombi.Schedule/JobSetup.cs index a4f05795b..e97882ce5 100644 --- a/src/Ombi.Schedule/JobSetup.cs +++ b/src/Ombi.Schedule/JobSetup.cs @@ -21,7 +21,7 @@ namespace Ombi.Schedule { RecurringJob.AddOrUpdate(() => Cacher.CacheContent(), Cron.Hourly); RecurringJob.AddOrUpdate(() => RadarrCacher.CacheContent(), Cron.Hourly); - RecurringJob.AddOrUpdate(() => Updater.Update(), Cron.Minutely); + RecurringJob.AddOrUpdate(() => Updater.Update(), Cron.Daily); } } } diff --git a/src/Ombi.Settings/Settings/Models/LandingPageSettings.cs b/src/Ombi.Settings/Settings/Models/LandingPageSettings.cs index b44ed1fce..c302c0c21 100644 --- a/src/Ombi.Settings/Settings/Models/LandingPageSettings.cs +++ b/src/Ombi.Settings/Settings/Models/LandingPageSettings.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; namespace Ombi.Core.Settings.Models @@ -6,17 +7,15 @@ namespace Ombi.Core.Settings.Models public class LandingPageSettings : Ombi.Settings.Settings.Models.Settings { public bool Enabled { get; set; } - public bool BeforeLogin { get; set; } - - [JsonIgnore] - public bool AfterLogin => !BeforeLogin; - + + [NotMapped] public bool NoticeEnabled => !string.IsNullOrEmpty(NoticeText); public string NoticeText { get; set; } - public string NoticeBackgroundColor { get; set; } public bool TimeLimit { get; set; } public DateTime StartDateTime { get; set; } public DateTime EndDateTime { get; set; } + [NotMapped] + public bool Expired => EndDateTime > DateTime.Now; } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/app.module.ts b/src/Ombi/ClientApp/app/app.module.ts index 87fe9f79e..1bcdd5a46 100644 --- a/src/Ombi/ClientApp/app/app.module.ts +++ b/src/Ombi/ClientApp/app/app.module.ts @@ -47,6 +47,7 @@ const routes: Routes = [ //{ path: 'requests-grid', component: RequestGridComponent }, { path: 'login', component: LoginComponent }, + { path: 'login/:landing', component: LoginComponent }, { path: 'reset', component: ResetPasswordComponent }, { path: 'token', component: TokenResetPasswordComponent }, { path: 'landingpage', component: LandingPageComponent } diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index d5e1486b1..f3883d177 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -68,14 +68,14 @@ export interface IRadarrSettings extends IExternalSettings { export interface ILandingPageSettings extends ISettings { enabled: boolean, - beforeLogin: boolean, - afterLogin: boolean, + noticeEnabled: boolean, noticeText: string, - noticeBackgroundColor: string, + timeLimit: boolean, startDateTime: Date, endDateTime: Date, + expired:boolean, } export interface ICustomizationSettings extends ISettings { diff --git a/src/Ombi/ClientApp/app/landingpage/landingpage.component.html b/src/Ombi/ClientApp/app/landingpage/landingpage.component.html index 1705ede8e..af4329fd6 100644 --- a/src/Ombi/ClientApp/app/landingpage/landingpage.component.html +++ b/src/Ombi/ClientApp/app/landingpage/landingpage.component.html @@ -27,7 +27,7 @@
- +
diff --git a/src/Ombi/ClientApp/app/login/login.component.ts b/src/Ombi/ClientApp/app/login/login.component.ts index 6742d3eb4..ef703a0b0 100644 --- a/src/Ombi/ClientApp/app/login/login.component.ts +++ b/src/Ombi/ClientApp/app/login/login.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; +import { Router, ActivatedRoute } from '@angular/router'; import { FormGroup, Validators, FormBuilder } from '@angular/forms'; import { AuthService } from '../auth/auth.service'; @@ -20,7 +20,8 @@ export class LoginComponent implements OnInit { constructor(private authService: AuthService, private router: Router, private notify: NotificationService, private status: StatusService, - private fb: FormBuilder, private settingsService: SettingsService, private images: ImageService, private sanitizer: DomSanitizer) { + private fb: FormBuilder, private settingsService: SettingsService, private images: ImageService, private sanitizer: DomSanitizer, + private route: ActivatedRoute) { this.form = this.fb.group({ username: ["", [Validators.required]], password: ["", [Validators.required]] @@ -31,13 +32,25 @@ export class LoginComponent implements OnInit { this.router.navigate(['Wizard']); } }); + + this.route.params + .subscribe(params => { + this.landingFlag = params['landing']; + }); } form: FormGroup; customizationSettings : ICustomizationSettings; background: any; + landingFlag: boolean; ngOnInit(): void { + this.settingsService.getLandingPage().subscribe(x => { + debugger; + if (x.enabled && !this.landingFlag) { + this.router.navigate(['landingpage']); + } + }); this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x); this.images.getRandomBackground().subscribe(x => { this.background = this.sanitizer.bypassSecurityTrustStyle('linear-gradient(-10deg, transparent 20%, rgba(0,0,0,0.7) 20.0%, rgba(0,0,0,0.7) 80.0%, transparent 80%),url(' + x.url + ')'); diff --git a/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.html b/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.html index 8a4842363..f4d09a9dc 100644 --- a/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.html +++ b/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.html @@ -11,20 +11,11 @@ - - - -
-
- - -
-

Notice Message

- +
@@ -33,6 +24,28 @@
+ +
+
+ + +
+
+ + + + + + + +
diff --git a/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.ts b/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.ts index 98ffd3f6c..b450b98d0 100644 --- a/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.ts +++ b/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.ts @@ -15,7 +15,9 @@ export class LandingPageComponent implements OnInit { settings: ILandingPageSettings; ngOnInit(): void { - this.settingsService.getLandingPage().subscribe(x => this.settings = x); + this.settingsService.getLandingPage().subscribe(x => { + this.settings = x + }); } save() { diff --git a/src/Ombi/ClientApp/app/settings/settings.module.ts b/src/Ombi/ClientApp/app/settings/settings.module.ts index 7502ff19a..6d168b665 100644 --- a/src/Ombi/ClientApp/app/settings/settings.module.ts +++ b/src/Ombi/ClientApp/app/settings/settings.module.ts @@ -26,7 +26,7 @@ import { NotificationTemplate } from './notifications/notificationtemplate.compo import { SettingsMenuComponent } from './settingsmenu.component'; import { HumanizePipe } from '../pipes/HumanizePipe'; -import { MenuModule, InputSwitchModule, InputTextModule, TooltipModule, AutoCompleteModule } from 'primeng/primeng'; +import { MenuModule, InputSwitchModule, InputTextModule, TooltipModule, AutoCompleteModule, CalendarModule } from 'primeng/primeng'; const routes: Routes = [ { path: 'Settings/Ombi', component: OmbiComponent, canActivate: [AuthGuard] }, @@ -53,7 +53,8 @@ const routes: Routes = [ NgbModule, TooltipModule, NgbAccordionModule, - AutoCompleteModule + AutoCompleteModule, + CalendarModule, ], declarations: [ SettingsMenuComponent, diff --git a/src/Ombi/Controllers/TokenController.cs b/src/Ombi/Controllers/TokenController.cs index 09a6b7ff7..d65882110 100644 --- a/src/Ombi/Controllers/TokenController.cs +++ b/src/Ombi/Controllers/TokenController.cs @@ -20,15 +20,17 @@ namespace Ombi.Controllers public class TokenController { public TokenController(UserManager um, IOptions ta, - IApplicationConfigRepository config) + IApplicationConfigRepository config, IAuditRepository audit) { UserManager = um; TokenAuthenticationOptions = ta.Value; Config = config; + Audit = audit; } private TokenAuthentication TokenAuthenticationOptions { get; } private IApplicationConfigRepository Config { get; } + private IAuditRepository Audit { get; } private UserManager UserManager { get; } /// @@ -39,6 +41,8 @@ namespace Ombi.Controllers [HttpPost] public async Task GetToken([FromBody] UserAuthModel model) { + await Audit.Record(AuditType.None, AuditArea.Authentication, + $"Username {model.Username} attempting to authenticate"); var user = await UserManager.FindByNameAsync(model.Username); diff --git a/src/Ombi/Startup.cs b/src/Ombi/Startup.cs index 3ab39cdec..480551082 100644 --- a/src/Ombi/Startup.cs +++ b/src/Ombi/Startup.cs @@ -166,7 +166,7 @@ namespace Ombi #if DEBUG // Note .AddMiniProfiler() returns a IMiniProfilerBuilder for easy intellisense - services.AddMiniProfiler(); + //services.AddMiniProfiler(); #endif // Make sure you have memory cache available unless you're using another storage provider services.AddMemoryCache(); @@ -245,19 +245,19 @@ namespace Ombi HotModuleReplacement = true }); - app.UseMiniProfiler(new MiniProfilerOptions - { - // Path to use for profiler URLs - RouteBasePath = "~/profiler", + //app.UseMiniProfiler(new MiniProfilerOptions + //{ + // // Path to use for profiler URLs + // RouteBasePath = "~/profiler", - // (Optional) Control which SQL formatter to use - // (default is no formatter) - SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter(), + // // (Optional) Control which SQL formatter to use + // // (default is no formatter) + // SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter(), - // (Optional) Control storage - // (default is 30 minutes in MemoryCacheStorage) - Storage = new MemoryCacheStorage(cache, TimeSpan.FromMinutes(60)), - }); + // // (Optional) Control storage + // // (default is 30 minutes in MemoryCacheStorage) + // Storage = new MemoryCacheStorage(cache, TimeSpan.FromMinutes(60)), + //}); } app.UseHangfireServer(); diff --git a/src/Ombi/Views/_ViewImports.cshtml b/src/Ombi/Views/_ViewImports.cshtml index 68275b28b..13274f512 100644 --- a/src/Ombi/Views/_ViewImports.cshtml +++ b/src/Ombi/Views/_ViewImports.cshtml @@ -1,4 +1,4 @@ @using Ombi @addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" @addTagHelper "*, Microsoft.AspNetCore.SpaServices" -@addTagHelper *, MiniProfiler.AspNetCore.Mvc \ No newline at end of file +@*@addTagHelper *, MiniProfiler.AspNetCore.Mvc*@ \ No newline at end of file