mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-01 12:34:40 +00:00
Logout button for forms Auth and fix UrlBase redirects
This commit is contained in:
parent
aa9df49ea2
commit
754c1ea331
5 changed files with 33 additions and 13 deletions
|
@ -4,17 +4,21 @@
|
||||||
using Nancy.Extensions;
|
using Nancy.Extensions;
|
||||||
using Nancy.ModelBinding;
|
using Nancy.ModelBinding;
|
||||||
using NzbDrone.Core.Authentication;
|
using NzbDrone.Core.Authentication;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
|
|
||||||
namespace NzbDrone.Api.Authentication
|
namespace NzbDrone.Api.Authentication
|
||||||
{
|
{
|
||||||
public class LoginModule : NancyModule
|
public class AuthenticationModule : NancyModule
|
||||||
{
|
{
|
||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
|
private readonly IConfigFileProvider _configFileProvider;
|
||||||
|
|
||||||
public LoginModule(IUserService userService)
|
public AuthenticationModule(IUserService userService, IConfigFileProvider configFileProvider)
|
||||||
{
|
{
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
|
_configFileProvider = configFileProvider;
|
||||||
Post["/login"] = x => Login(this.Bind<LoginResource>());
|
Post["/login"] = x => Login(this.Bind<LoginResource>());
|
||||||
|
Get["/logout"] = x => Logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response Login(LoginResource resource)
|
private Response Login(LoginResource resource)
|
||||||
|
@ -35,5 +39,10 @@ private Response Login(LoginResource resource)
|
||||||
|
|
||||||
return this.LoginAndRedirect(user.Identifier, expiry);
|
return this.LoginAndRedirect(user.Identifier, expiry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response Logout()
|
||||||
|
{
|
||||||
|
return this.LogoutAndRedirect(_configFileProvider.UrlBase + "/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -64,7 +64,7 @@ private void RegisterFormsAuth(IPipelines pipelines)
|
||||||
|
|
||||||
FormsAuthentication.Enable(pipelines, new FormsAuthenticationConfiguration
|
FormsAuthentication.Enable(pipelines, new FormsAuthenticationConfiguration
|
||||||
{
|
{
|
||||||
RedirectUrl = "~/login",
|
RedirectUrl = _configFileProvider.UrlBase + "/login",
|
||||||
UserMapper = _authenticationService,
|
UserMapper = _authenticationService,
|
||||||
CryptographyConfiguration = cryptographyConfiguration
|
CryptographyConfiguration = cryptographyConfiguration
|
||||||
});
|
});
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Authentication\AuthenticationService.cs" />
|
<Compile Include="Authentication\AuthenticationService.cs" />
|
||||||
<Compile Include="Authentication\EnableAuthInNancy.cs" />
|
<Compile Include="Authentication\EnableAuthInNancy.cs" />
|
||||||
<Compile Include="Authentication\LoginModule.cs" />
|
<Compile Include="Authentication\AuthenticationModule.cs" />
|
||||||
<Compile Include="Authentication\LoginResource.cs" />
|
<Compile Include="Authentication\LoginResource.cs" />
|
||||||
<Compile Include="Authentication\NzbDroneUser.cs" />
|
<Compile Include="Authentication\NzbDroneUser.cs" />
|
||||||
<Compile Include="Blacklist\BlacklistModule.cs" />
|
<Compile Include="Blacklist\BlacklistModule.cs" />
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var $ = require('jquery');
|
var $ = require('jquery');
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
var Marionette = require('marionette');
|
var Marionette = require('marionette');
|
||||||
var SystemInfoLayout = require('./Info/SystemInfoLayout');
|
var SystemInfoLayout = require('./Info/SystemInfoLayout');
|
||||||
|
@ -7,6 +7,7 @@ var UpdateLayout = require('./Update/UpdateLayout');
|
||||||
var BackupLayout = require('./Backup/BackupLayout');
|
var BackupLayout = require('./Backup/BackupLayout');
|
||||||
var TaskLayout = require('./Task/TaskLayout');
|
var TaskLayout = require('./Task/TaskLayout');
|
||||||
var Messenger = require('../Shared/Messenger');
|
var Messenger = require('../Shared/Messenger');
|
||||||
|
var StatusModel = require('./StatusModel');
|
||||||
|
|
||||||
module.exports = Marionette.Layout.extend({
|
module.exports = Marionette.Layout.extend({
|
||||||
template : 'System/SystemLayoutTemplate',
|
template : 'System/SystemLayoutTemplate',
|
||||||
|
@ -25,18 +26,22 @@ module.exports = Marionette.Layout.extend({
|
||||||
tasksTab : '.x-tasks-tab'
|
tasksTab : '.x-tasks-tab'
|
||||||
},
|
},
|
||||||
events : {
|
events : {
|
||||||
"click .x-info-tab" : '_showInfo',
|
'click .x-info-tab' : '_showInfo',
|
||||||
"click .x-logs-tab" : '_showLogs',
|
'click .x-logs-tab' : '_showLogs',
|
||||||
"click .x-updates-tab" : '_showUpdates',
|
'click .x-updates-tab' : '_showUpdates',
|
||||||
"click .x-backup-tab" : '_showBackup',
|
'click .x-backup-tab' : '_showBackup',
|
||||||
"click .x-tasks-tab" : '_showTasks',
|
'click .x-tasks-tab' : '_showTasks',
|
||||||
"click .x-shutdown" : '_shutdown',
|
'click .x-shutdown' : '_shutdown',
|
||||||
"click .x-restart" : '_restart'
|
'click .x-restart' : '_restart'
|
||||||
},
|
},
|
||||||
initialize : function(options){
|
initialize : function(options){
|
||||||
if(options.action) {
|
if(options.action) {
|
||||||
this.action = options.action.toLowerCase();
|
this.action = options.action.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.templateHelpers = {
|
||||||
|
authentication : StatusModel.get('authentication')
|
||||||
|
};
|
||||||
},
|
},
|
||||||
onShow : function(){
|
onShow : function(){
|
||||||
switch (this.action) {
|
switch (this.action) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li><a href="#info" class="x-info-tab no-router">Info</a></li>
|
<li><a href="#info" class="x-info-tab no-router">Info</a></li>
|
||||||
<li><a href="#logs" class="x-logs-tab no-router">Logs</a></li>
|
<li><a href="#logs" class="x-logs-tab no-router">Logs</a></li>
|
||||||
<li><a href="#updates" class="x-updates-tab no-router">Updates</a></li>
|
<li><a href="#updates" class="x-updates-tab no-router">Updates</a></li>
|
||||||
|
@ -12,6 +12,12 @@
|
||||||
<button class="btn btn-default btn-icon-only x-restart" title="Restart" data-container="body">
|
<button class="btn btn-default btn-icon-only x-restart" title="Restart" data-container="body">
|
||||||
<i class="icon-nd-restart"></i>
|
<i class="icon-nd-restart"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
{{#if_eq authentication compare="forms"}}
|
||||||
|
<a href="{{UrlBase}}/logout" class="btn btn-default btn-icon-only" title="Logout" data-container="body">
|
||||||
|
<i class="icon-lock"></i>
|
||||||
|
</a>
|
||||||
|
{{/if_eq}}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in a new issue