Redirect to the landing page when enabled #1458 #865

pull/1488/head
Jamie.Rees 7 years ago
parent 046211e017
commit bd27e4ad70

@ -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);
}
}
}

@ -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;
}
}

@ -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 }

@ -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 {

@ -27,7 +27,7 @@
</div>
</div>
<div class="col-md-3 col-md-push-4 vcenter">
<button [routerLink]="['/search']" class="btn btn-lg btn-success-outline">Contine</button>
<button [routerLink]="['/login', 'true']" class="btn btn-lg btn-success-outline">Contine</button>
</div>
</div>
</div>

@ -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 + ')');

@ -11,20 +11,11 @@
<label for="enable">Enable</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="BeforeLogin" name="BeforeLogin" [(ngModel)]="settings.beforeLogin" ng-checked="settings.beforeLogin" tooltipPosition="top" pTooltip="If enabled then this will show the landing page before the login page, if this is disabled the user will log in first and then see the landing page.">
<label for="BeforeLogin">Show before the login</label>
</div>
</div>
<p class="form-group">Notice Message</p>
<div class="form-group">
<div>
<textarea rows="4" type="text" class="form-control-custom form-control " id="NoticeMessage" name="NoticeMessage" placeholder="e.g. The server will be down for maintaince (HTML is allowed)" [(ngModel)]="settings.noticeText" >{{noticeText}}</textarea>
<textarea rows="4" type="text" class="form-control-custom form-control " id="NoticeMessage" name="NoticeMessage" placeholder="e.g. The server will be down for maintaince (HTML is allowed)" [(ngModel)]="settings.noticeText">{{noticeText}}</textarea>
</div>
</div>
@ -33,6 +24,28 @@
<div [innerHTML]="settings.noticeText"></div>
</div>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="enable" name="enable" [(ngModel)]="settings.timeLimit" ng-checked="settings.timeLimit">
<label for="enable">Only show the notification message between the below times</label>
</div>
</div>
<!--<p class="form-group">Start Time</p>
<div class="form-group">
<p-calendar [(ngModel)]="settings.startDateTime" [showTime]="true"></p-calendar>
</div>
<p class="form-group">End Time</p>
<div class="form-group">
<p-calendar [(ngModel)]="settings.endDateTime" [showTime]="true"></p-calendar>
</div>-->
<div class="form-group">
<div>
<button (click)="save()" type="submit" id="save" class="btn btn-primary-outline">Submit</button>

@ -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() {

@ -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,

@ -20,15 +20,17 @@ namespace Ombi.Controllers
public class TokenController
{
public TokenController(UserManager<OmbiUser> um, IOptions<TokenAuthentication> 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<OmbiUser> UserManager { get; }
/// <summary>
@ -39,6 +41,8 @@ namespace Ombi.Controllers
[HttpPost]
public async Task<IActionResult> GetToken([FromBody] UserAuthModel model)
{
await Audit.Record(AuditType.None, AuditArea.Authentication,
$"Username {model.Username} attempting to authenticate");
var user = await UserManager.FindByNameAsync(model.Username);

@ -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();

@ -1,4 +1,4 @@
@using Ombi
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
@addTagHelper "*, Microsoft.AspNetCore.SpaServices"
@addTagHelper *, MiniProfiler.AspNetCore.Mvc
@*@addTagHelper *, MiniProfiler.AspNetCore.Mvc*@
Loading…
Cancel
Save